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.

RDBMS Stored Procedure Details<br />

3–16<br />

/* Return status */<br />

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

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

RUN STORED-PROCEDURE pcust handle1 = PROC-HANDLE (20, output 0, output 0).<br />

CLOSE STORED-PROC pcust stat = PROC-STATUS WHERE PROC-HANDLE = handle1.<br />

IF stat = 0 THEN<br />

DISPLAY “procedure succeeded”.<br />

Example 3–4: Return status example<br />

Retrieving output parameter values<br />

When you call a stored procedure, you can specify the ordered list of positional parameters or<br />

you can name them individually. To retrieve output parameter values from a stored procedure,<br />

request them with the keyword OUTPUT or INPUT–OUTPUT when you execute the procedure.<br />

When you run a stored procedure in a <strong>Data</strong><strong>Server</strong> application, the parameters are supplied and<br />

passed using <strong>OpenEdge</strong> data types.<br />

Example 3–5, an ABL procedure, uses the second option <strong>for</strong> passing parameters—it passes<br />

them by name with the PARAM option.<br />

/* Parameters by name */<br />

RUN STORED-PROC pcust (PARAM num = 20, OUTPUT PARAM states = 0,<br />

OUTPUT PARAM orders = 0).<br />

CLOSE STORED-PROC pcust.<br />

DISPLAY pcust.orders pcust.states.<br />

Example 3–5: Passing parameters by name using the PARAM option<br />

When you use PARAM to specify parameter names, you do not have to specify all parameters <strong>for</strong><br />

the stored procedure. Instead, you can include only those parameters you want to use, in any<br />

order you choose. If the stored procedure names a default value <strong>for</strong> the parameter, you do not<br />

have to name that parameter at run time. However, you must explicitly name parameters that do<br />

not have defaults or name them when you want to pass values that are different from the default.<br />

Retrieving result sets using proc-text-buffer<br />

The proc–text–buffer technique offers one approach to access results returned from a data<br />

source. The following is the partial syntax <strong>for</strong> the DEFINE BUFFER statement that you use to<br />

create a buffer with the same characteristics of the proc–text–buffer:<br />

Syntax<br />

DEFINE BUFFER buffer-name FOR proc-text-buffer<br />

For a complete description, see the reference entry that discusses the DEFINE BUFFER<br />

statement in <strong>OpenEdge</strong> Development: ABL Reference.

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

Saved successfully!

Ooh no, something went wrong!