Using ROWID with RUN STORED-PROCEDURE and LOAD-RESULT-INTO
- Last Updated: May 30, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
The example in the previous section assumes you migrated your database to MS SQL Server using
the Create RECID Fieldoption, as discussed in ROWID characteristics. The examples in this section show ROWID as being represented by the
8-byte integer value of the PROGRESS_RECID column as opposed to some other
unique single-component index designated in your database to be the
PROGRESS_RECID.
ROWID of a temp-table, you would need
to map the column accordingly, just as the example maps PROGRESS_RECID.The RUN STORED-PROC command has no native awareness that the MS SQL Server
Database table is being queried for the result set(s) it generates. Therefore, to allow
DataServer technology to convert the stored PROGRESS_RECID value into a
native OpenEdge ROWID value, the physical name of the target database table
needs to be known. To achieve this bond, the temp-table that the stored procedure populates
must be associated with an OpenEdge ProDataSet object.
ABL Query filling a ProDataSet temp-table
The following example shows an ABL query filling the temp tables of a ProDataSet. It will be used as the baseline code referenced throughout the remainder of this section.
|
If the table uses
computed-column PROGRESS_RECID option, then ttCustomer temp-table
definition should be:
|
Using the LOAD-RESULT-INTO technique to populate the underlying Temp-Table of a ProDataSet
RUN STORED-PROC
[LOAD-RESULT-INTO] technique, rather than an ABL query, to fill the
TEMP-TABLE associated with a ProDataSet.
|
Keep the following key points in mind regarding this example:
- The
TEMP-TABLEfield that is mapped to thePROGRESS_RECIDcolumn should be changed from its standard definition ofINTEGERtoROWID.The result column location where
PROGRESS_RECIDis being returned has been namedtRecidin the temp-table. ThePROGRESS_RECID_IDENThas been renamedtRECID_ident. This renaming occurs because of the following line:FIELD tRecid AS ROWID /* must be changed to ROWID type */ FIELD tRECID_ident AS INTEGER.If the table uses the computed-column
PROGRESS_RECIDoption, then thettCustomertemp-table definition should be:DEFINE TEMP-TABLE ttCustomer LIKE Sports.Customer FIELD tRecid AS ROWID /* Must be changed to ROWID type */ FIELD tRECID_ident AS INT64 FIELD tRECID_alt as INT64. - The
TEMP-TABLEmust be defined to the ProDataSet. The following line excerpted from the complete example shows this definition:DEFINE DATASET dsCustomer FOR ttCustomer. - The demonstrated technique does not change the default behavior of the
ROWIDfunction, but provides a mechanism for theROWIDvalue to be stored along side its corresponding result rows; therefore, using theROWIDvalue to access database rows is unconventional with respect to the normal, or more typical, association betweenROWIDand a database table row. The following code demonstrates this difference.Default use of
ROWIDfunction on a record buffer, as excerpted:FIND FIRST Customer WHERE Customer.CustNum = 1 NO-LOCK. rid-1 = ROWID(Customer).In contrast, the following code excerpt demonstrates an alternative use of the
ROWIDvalue with a temp-table:FIND FIRST Customer WHERE Customer.CustNum = 1 NO-LOCK. rid-2 = ttCustomer.tRecid.