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 />

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 rdi-2 AS ROWID NO-UNDO.<br />

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

FIELD tRecid AS ROWID<br />

FIELD tRECID_ident AS INTEGER.<br />

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

DEFINE DATASET dsCustomer FOR ttCustomer.<br />

DEFINE QUERY qCustomer FOR Customer.<br />

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

ph<strong>Data</strong>Set:SET-CALLBACK-PROCEDURE<br />

(“BEFORE-FILL”, “pre<strong>Data</strong>SetFill”, THIS-PROCEDURE).<br />

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

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

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

DATASET dsCustomer:FILL().<br />

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

rid-1 = ROWID(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 EQ rid-2 THEN<br />

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

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

PROCEDURE pre<strong>Data</strong>SetFill:<br />

DEFINE INPUT PARAMETER DATASET FOR dsCustomer.<br />

DEFINE VARIABLE handle1 AS INTEGER NO-UNDO.<br />

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

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

IF DBTYPE(NUM-DBS) NE ”PROGRESS” THEN DO:<br />

DISPLAY “<strong>Data</strong><strong>Server</strong> FILL using SEND-<strong>SQL</strong>”.<br />

BUFFER ttCustomer:HANDLE:FILL-MODE = ”NO-FILL”.<br />

RUN STORED-PROC send-sql-statement LOAD-RESULT-INTO hSend<strong>SQL</strong><br />

(“select * from customer”).<br />

END.<br />

ELSE DO: /* normal OpenEddge FILL procedure */<br />

DISPLAY “Native Progress FILL”.<br />

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

END.<br />

END PROCEDURE. /* pre<strong>Data</strong>SetFill */<br />

Example 27: Use the LOAD-RESULT-INTO technique with BEFORE-FILL<br />

method to fill the temp-table(s) of a Pro<strong>Data</strong>Set<br />

158 <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!