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.

Run Stored-Proc statement execution with the<br />

LOAD-RESULT-INTO phrase<br />

Run Stored-Procedure details<br />

You can also execute a stored procedure implementation to obtain result sets and load the results<br />

into temp-tables. You must define result set(s) target as part of the RUN STORED-PROC statement.<br />

You do not explicitly close a STORED-PROC defined this way as you do with buffer methods of<br />

retrieving result sets; the LOAD-RESULT-INTO function achieves this goal implicitly.<br />

This is the syntax <strong>for</strong> the RUN STORED–PROC statement implementation when loading result sets<br />

to temp-tables:<br />

Syntax<br />

RUN STORED-PROC procedure-name<br />

[[LOAD-RESULT-INTO [ = PROC-STATUS]]<br />

[NO-ERROR]<br />

[([INPUT|OUTPUT|INPUT OUTPUT] [PARAM parameter-name =]expression, ...<br />

[INPUT|OUTPUT|INPUT OUTPUT] [PARAM parameter-name =]expression)]<br />

The RUN STORED-PROC statement sets up the execution of the stored-procedure, retrieves the<br />

result set(s), and loads it into the temp-table(s) provided you use the LOAD-RESULT-INTO<br />

function. The CLOSE STORED-PROC statement is automatically applied when the result set(s) is<br />

loaded into temp-tables because using temp-tables must consume all result sets of the<br />

procedure.<br />

Run Stored-Proc statement execution using the<br />

send-sql-statement option<br />

ABL also allows you to use stored-procedure syntax to send <strong>SQL</strong> statements and their native<br />

language extensions directly to a data source. The <strong>Data</strong><strong>Server</strong> uses the RUN STORED–PROCEDURE<br />

statement with the send–sql–statement option to pass <strong>SQL</strong> statements to the data source. This<br />

option gives you access to Transact–<strong>SQL</strong>, providing you access to business logic <strong>for</strong> MS <strong>SQL</strong><br />

<strong>Server</strong>. For example, you can issue <strong>Data</strong> Definition Language (DDL) statements from within<br />

<strong>OpenEdge</strong> procedures. You can send multiple <strong>SQL</strong> statements by concatenating them and<br />

passing the string as a single parameter to the send–sql–statement option.<br />

Like the option to define a RUN STORED-PROC statement either with or without the<br />

LOAD-RESULT-INTO options, you can define a send-sql-statement with or without the<br />

LOAD-RESULT-INTO option. The following section presents and briefly describes a sample use of<br />

each technique.<br />

Without the Load-Result-Into option<br />

You use the RUN STORED–PROC statement with the send–sql–statement option and pass the<br />

Transact-<strong>SQL</strong> statements as a parameter. The syntax of the statement must be valid<br />

Transact-<strong>SQL</strong> syntax. Example 3–1 shows how this code passes a SELECT statement as a<br />

parameter.<br />

Note: The <strong>SQL</strong> statement(s) passed to the send-sql-statement stored procedure is not limited<br />

to the 32,000 bytes of a <strong>OpenEdge</strong> CHARACTER field. To pass <strong>SQL</strong> of greater size, store<br />

the <strong>SQL</strong> text in a LONGCHAR field and pass that as a parameter to the send-sql-statement<br />

stored procedure.<br />

3–11

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

Saved successfully!

Ooh no, something went wrong!