13.01.2013 Views

OpenEdge Data Management: DataServer for Microsoft SQL Server

OpenEdge Data Management: DataServer for Microsoft SQL Server

OpenEdge Data Management: DataServer for Microsoft SQL Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

RDBMS Stored Procedure Details<br />

3–34<br />

Using ROWID with RUN STORED-PROCEDURE and<br />

LOAD-RESULT-INTO<br />

In the previous section, Example 3–24 assumes you migrated your database to MS <strong>SQL</strong> <strong>Server</strong><br />

using the Create RECID Field option, as discussed in the “ROWID characteristics” section<br />

on page 3–32. Example 3-24 and all subsequent examples in this section show ROWID as being<br />

represented by the 8-byte integer value of the PROGRESS_RECID column as opposed to some<br />

other unique single-component index designated in your database to be the PROGRESS_RECID.<br />

Note: If you used a different single-component index to load the ROWID of a temp-table, you<br />

would need to map the column accordingly, just as the example maps<br />

PROGRESS_RECID.<br />

The RUN STORED-PROC command has no native awareness that the MS <strong>SQL</strong> <strong>Server</strong> <strong>Data</strong>base<br />

table is being queried <strong>for</strong> the result set(s) it generates. There<strong>for</strong>e, to allow <strong>Data</strong><strong>Server</strong><br />

technology to convert the stored PROGRESS_RECID value into a native <strong>OpenEdge</strong> ROWID value,<br />

the physical name of the target database table needs to be known. To achieve this bond, the<br />

temp-table that the stored procedure will populate must be associated with an <strong>OpenEdge</strong><br />

Pro<strong>Data</strong>Set object.<br />

Example 3–25 shows an ABL query filling the temp tables of a Pro<strong>Data</strong>Set. It will be used as<br />

the baseline code which will be referenced throughout the remainder of this section.<br />

DEFINE VARIABLE ph<strong>Data</strong>Set AS HANDLE NO-UNDO.<br />

DEFINE TEMP-TABLE ttCustomer LIKE Sports2000.Customer<br />

FIELD tRecid AS INTEGER<br />

FIELD tRECID_ident AS INTEGER.<br />

DEFINE DATASET dsCustomer FOR ttCustomer.<br />

DEFINE QUERY qCustomer FOR Customer.<br />

ph<strong>Data</strong>Set=DATASET dsCustomer:HANDLE.<br />

DEFINE DATA-SOURCE srcCustomer FOR QUERY qCustomer.<br />

BUFFER ttCustomer:HANDLE:ATTACH-DATA-SOURCE<br />

(DATA-SOURCE srcCustomer:HANDLE,?,?,?).<br />

QUERY qCustomer:QUERY-PREPARE (“FOR EACH Customer”).<br />

DATASET dsCustomer:FILL().<br />

FOR EACH ttCustomer:<br />

DISPLAY ttCustomer.name ttCustomer.tRecid.<br />

END.<br />

Example 3–25: ABL Query filling a Pro<strong>Data</strong>Set temp-table

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!