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.

Chapter 3: RDBMS Stored Procedure Details<br />

Example 26 combines code from Example 24 and Example 25 by applying the results<br />

of the RUN STORED-PROC [LOAD-RESULT-INTO] technique, rather than an ABL query,<br />

to fill the TEMP-TABLE associated with a Pro<strong>Data</strong>Set.<br />

DEFINE VARIABLE hSend<strong>SQL</strong> AS HANDLE NO-UNDO EXTENT 1.<br />

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

DEFINE VARIABLE rid-1 AS ROWID NO-UNDO.<br />

DEFINE VARIABLE rid-2 AS ROWID NO-UNDO.<br />

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

FIELD tRecid AS ROWID /* Must be changed to ROWID type */<br />

FIELD tRECID_ident AS INT64.<br />

hSend<strong>SQL</strong>[1] = TEMP-TABLE ttCust:HANDLE.<br />

DEFINE DATASET dsCustomer FOR ttCustomer.<br />

DEFINE QUERY qCustomer FOR Customer.<br />

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

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

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

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

FIND FIRST Customer WHERE Customer.CustNum = 1 NO_LOCK.<br />

rid-1 = ROWID(Customer).<br />

/* Populate the ttCustomer Temp-Table */<br />

RUN STORED-PROC send-sql-statement<br />

LOAD-RESULT-INTO hSend<strong>SQL</strong> (“select * from customer”).<br />

FIND FIRST ttCustomer WHERE ttCustomer.CustNum = 1 NO-LOCK.<br />

rid-2 = ttCustomer.tRecid.<br />

If rid-1 NE rid-2 THEN<br />

MESSAGE “The same record but different ROWID’s”.<br />

IF rid-1 = rid-2 THEN<br />

MESSAGE “Congratulations - we have the same ROWID’s”.<br />

MESSAGE STRING(ttCustomer.tRecid) VIEW-AS ALERT-BOX.<br />

Example 26: Using the LOAD-RESULT-INTO technique to populate the<br />

underlying Temp-Table of a Pro<strong>Data</strong>Set<br />

Keep the following key points in mind regarding Example 26:<br />

• The TEMP-TABLE field that is mapped to the PROGRESS_RECID column should be<br />

changed from its standard definition of INTEGER to ROWID.<br />

In Example 26, the result column location where PROGRESS_RECID is being<br />

returned has been named tRecid in the temp-table. The PROGRESS_RECID_IDENT<br />

has been renamed tRECID_ident. This renaming occurs in Example 3-26<br />

because of the following line:<br />

FIELD tRecid AS ROWID /* must be changed to ROWID type */<br />

FIELD tRECID_ident AS INTEGER.<br />

156 <strong>OpenEdge</strong> <strong>Data</strong> <strong>Management</strong>: <strong>Data</strong><strong>Server</strong> <strong>for</strong> <strong>Microsoft</strong> <strong>SQL</strong> <strong>Server</strong>

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

Saved successfully!

Ooh no, something went wrong!