Kbase P133173: 4GL/ABL: How to use the RAW-TRANSFER() method with a dynamic table buffer?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  11/07/2008 |
|
Status: Unverified
GOAL:
4GL/ABL: How to use the RAW-TRANSFER() method with a dynamic table buffer?
GOAL:
How to use the RAW-TRANSFER() method to pump the contents of records in RAW fields?
GOAL:
How to use the RAW-TRANSFER statement to pump the contents of RAW fields into table records?
GOAL:
How to pass a TEMP-TABLE as an INPUT-OUTPUT parameter?
GOAL:
How to marshal the data of a record into a RAW field using the RAW-TRANSFER() method?
GOAL:
How to un-marshal the data of a RAW field into a table record using the RAW-TRANSFER statement?
FACT(s) (Environment):
All Supported Operating Systems
Progress 9.x
OpenEdge 10.x
FIX:
1. The following DemoRawTransferStatement.p calling procedure demonstrates the use of the RAW-TRANSFER FIELD statement to pump the contents of RAW fields into table records. It also demonstrates how to pass a TEMP-TABLE as an INPUT-OUTPUT TABLE parameter:
/*** DemoRawTransferStatement.p ***/
DEFINE VARIABLE cTableName AS CHARACTER NO-UNDO.
DEFINE TEMP-TABLE ttRawFieldTable NO-UNDO
FIELD rawField AS RAW.
DEFINE TEMP-TABLE ttCutsomer LIKE customer.
ASSIGN
cTableName = "Customer".
RUN DemoRawTransferMethod.p(INPUT-OUTPUT TABLE ttRawFieldTable, INPUT cTableName ).
/* Use the RAW-TRANSFER FIELD statement to pump the contents of RAW fields into table records */
FOR EACH ttRawFieldTable NO-LOCK:
CREATE ttCutsomer.
RAW-TRANSFER FIELD ttRawFieldTable.rawField TO BUFFER ttCutsomer NO-ERROR.
END.
/* Display some fields from the table populated using the RAW-TRANSFER FIELD statement */
FOR EACH ttCutsomer:
DISPLAY ttCutsomer.CustNum ttCutsomer.Name ttCutsomer.Balance.
END.
2. The following DemoRawTransferMethod.p called procedure demonstrates the use of the RAW-TRANSFER() method with a dynamic table buffer. It also illustrates how to use the RAW-TRANSFER() method to pump the contents of records in RAW fields:
/*** DemoRawTransferMethod.p ***/
DEFINE TEMP-TABLE ttRawFieldTable NO-UNDO
FIELD rawField AS RAW.
DEFINE INPUT-OUTPUT PARAMETER TABLE FOR ttRawFieldTable.
DEFINE INPUT PARAMETER ipcTableName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cTableName AS CHARACTER NO-UNDO.
DEFINE VARIABLE hBufferHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE hFieldHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE hTempTableBuffer AS HANDLE NO-UNDO.
ASSIGN
cTableName = ipcTableName.
CREATE BUFFER hTempTableBuffer FOR TABLE "ttRawFieldTable".
CREATE BUFFER hBufferHandle FOR TABLE cTableName.
CREATE QUERY hQuery.
hQuery:SET-BUFFERS(hBufferHandle).
hQuery:QUERY-PREPARE("FOR EACH " + cTableName + " NO-LOCK").
hQuery:QUERY-OPEN.
/* Use the RAW-TRANSFER method to pump the contents of the record buffer into a RAW field */
REPEAT:
hQuery:GET-NEXT().
IF hQuery:QUERY-OFF-END THEN LEAVE.
DO TRANSACTION:
hQuery:GET-CURRENT(EXCLUSIVE-LOCK).
hTempTableBuffer:BUFFER-CREATE ().
ASSIGN
hFieldHandle = hTempTableBuffer:BUFFER-FIELD("rawField").
hBufferHandle:RAW-TRANSFER (TRUE, hFieldHandle) NO-ERROR.
END.
END.
/* Clean up */
hQuery:QUERY-CLOSE.
DELETE OBJECT hQuery NO-ERROR.
DELETE OBJECT hTempTableBuffer NO-ERROR.
DELETE OBJECT hBufferHandle NO-ERROR.