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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Interfacing with RDBMS stored procedures<br />

defined in the temp-table that will receive the result set. No mapping exists between the<br />

result set and the temp-table. There<strong>for</strong>e, the first field defined in the temp-table<br />

corresponds to the first column of the result set and so <strong>for</strong>th.<br />

Additional temp-table examples<br />

This section presents more examples that show various techniques to code<br />

temp-tables.<br />

Example 15 follows this initial explanation; the stored procedure myProc is comprised<br />

of two fields—one is an integer and the other is a character, and a result set.<br />

SELECT “myProc,” cust_num, cust_name FROM <br />

Example 15: Temp-table code technique<br />

Example 16 shows the basics of executing a call to a stored procedure using the<br />

LOAD-RESULT-INTO functionality. Note that in this example, PROC-STATUS function is<br />

not specified. There<strong>for</strong>e, there is no possibility of a return value.<br />

/* Calling a stored procedure, using the LOAD-RESULT-INTO phrase*/<br />

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

DEFINE VARIABLE ttHndl AS HANDLE NO-UNDO.<br />

DEFINE TEMP-TABLE ttl<br />

FIELD f1 AS INTEGER<br />

FIELD f2 AS CHARACTER.<br />

ttHndl = TEMP-TABLE tt:HANDLE.<br />

RUN STORED-PROC myProc LOAD-RESULT-INTO ttHndl (INPUT 1, OUTPUT res).<br />

Example 16: Basic execution of a stored procedure using<br />

LOAD-RESULT-INTO functionality<br />

Example 17 shows the basics of using an existing dynamic temp-table without the<br />

TEMP-TABLE-PREPARE () method. In this instance, send-sql-statement is used<br />

rather than a predefined stored proc. In contrast, the third example code that appears<br />

later in this section shows the same approach, but explicitly defines the existing<br />

dynamic temp-table with the TEMP-TABLE-PREPARE() method.<br />

/* Calling a stored procedure, using an existing temp-table without temp table<br />

prepare */<br />

DEFINE VARIABLE ttHndl AS HANDLE NO-UNDO.<br />

CREATE TEMP-TABLE ttHndl.<br />

RUN STORED-PROC send-sql-statement LOAD-RESULT-INTO ttHndl<br />

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

Example 17: Using an existing dynamic temp-table without the<br />

TEMP-TABLE-PREPARE ( ) method<br />

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

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

Saved successfully!

Ooh no, something went wrong!