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.

Interfacing with RDBMS stored procedures<br />

Example 3–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 not<br />

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 3–16: Basic execution of a stored procedure using<br />

LOAD-RESULT-INTO functionality<br />

Example 3–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 rather than a<br />

predefined stored proc. In contrast, the third example code that appears later in this section<br />

shows the same approach, but explicitly defines the existing dynamic temp-table with the<br />

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 3–17: Using an existing dynamic temp-table without the<br />

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

3–27

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

Saved successfully!

Ooh no, something went wrong!