Consultor Eletrônico



Kbase P181278: 4GL/ABL: How is the COPY-TEMP-TABLE() method used?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   1/26/2011
Status: Unverified

GOAL:

4GL/ABL: How is the COPY-TEMP-TABLE() method used?

GOAL:

Sample code using the 4GL/ABL COPY-TEMP-TABLE() method.

FACT(s) (Environment):

All Supported Operating Systems
OpenEdge 10.2B

FIX:

The following code uses the 4GL/ABL COPY-TEMP-TABLE() method showing how to pass one or more of its parameters:
DEFINE VARIABLE httSource AS HANDLE NO-UNDO.
DEFINE VARIABLE httTarget AS HANDLE NO-UNDO.
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.
/* Define the source and target temp tables */
DEFINE TEMP-TABLE ttSource LIKE Customer.
DEFINE TEMP-TABLE ttTarget LIKE Customer.
/* Assign the source and target temp table handles */
ASSIGN
httSource = TEMP-TABLE ttSource:HANDLE
httTarget = TEMP-TABLE ttTarget:HANDLE.
/* Pump the first 10 records in the source temp-table */
iCounter = 0.
FOR EACH Customer NO-LOCK:
iCounter = iCounter + 1.
IF iCounter > 10 THEN LEAVE.
CREATE ttSource.
BUFFER-COPY Customer TO ttSource.
END.
MESSAGE "Display initial 10 records of source temp table "
VIEW-AS ALERT-BOX INFO BUTTONS OK.
FOR EACH ttSource:
DISPLAY ttSource.CustNum ttSource.NAME.
END.
/* Use the COPY-TEMP-TABLE( ) method without any options */
httTarget:COPY-TEMP-TABLE( httSource,?,?,?,?).
MESSAGE "Confirm contents of source have been copied to target"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
FOR EACH ttTarget:
DISPLAY ttTarget.CustNum ttTarget.NAME.
END.
/* Empty the source temp table */
EMPTY TEMP-TABLE ttSource.
/* Pump 5 records in the source temp-table */
iCounter = 0.
FOR EACH Customer NO-LOCK WHERE custnum > 10:
iCounter = iCounter + 1.
IF iCounter > 5 THEN LEAVE.
CREATE ttSource.
BUFFER-COPY Customer TO ttSource.
END.
MESSAGE "Display new contents of source temp-table "
VIEW-AS ALERT-BOX INFO BUTTONS OK.
FOR EACH ttSource:
DISPLAY ttSource.CustNum ttSource.NAME.
END.
/* Use the COPY-TEMP-TABLE( ) method with append-mode */
httTarget:COPY-TEMP-TABLE( httSource,YES,?,?,?).
MESSAGE "Display contents of source that have been appended to target"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
FOR EACH ttTarget:
DISPLAY ttTarget.CustNum ttTarget.NAME.
END.
/* Use the COPY-TEMP-TABLE( ) method with no append-mode and replace-mode */
httTarget:COPY-TEMP-TABLE( httSource,NO,YES,?,?).
MESSAGE "Display result of Use the COPY-TEMP-TABLE( ) method with no append-mode and replace-mode "
VIEW-AS ALERT-BOX INFO BUTTONS OK.
FOR EACH ttTarget:
DISPLAY ttTarget.CustNum ttTarget.NAME.
END.
/* Empty the source temp table */
EMPTY TEMP-TABLE ttSource.
/* Pump 5 new records in the source temp-table */
iCounter = 0.
FOR EACH Customer NO-LOCK WHERE custnum > 15:
iCounter = iCounter + 1.
IF iCounter > 5 THEN LEAVE.
CREATE ttSource.
BUFFER-C.OPY Customer TO ttSource.
END.
/* Use the COPY-TEMP-TABLE( ) method with no append-mode and no replace-mode and loose-copy-mode */
httTarget:COPY-TEMP-TABLE( httSource,NO,NO,YES,?).
MESSAGE "Display result of no append-mode and no replace-mode and loose-copy-mode "
VIEW-AS ALERT-BOX INFO BUTTONS OK.
FOR EACH ttTarget:
DISPLAY ttTarget.CustNum ttTarget.NAME.
END..