skip to main content
OpenEdge Data Management: DataServer for ODBC
Programming Considerations : Stored procedures : Retrieving data-source results
 

Retrieving data-source results

OpenEdge provides two methods for accessing results returned from a data source by a stored procedure. You can:
*Use proc–text–buffer (without quoted text) or proc–text–buffer-q (with quoted text) to access result sets available through a pseudo table of which each row is a long character string.
Note: Referencing Proc-text-buffer with the -q extension enables you to access the character-converted results in quoted text (" ") from a data source. That is, proc-text-buffer-q causes quoted values in the character string and retains embedded quotes within the character result. You can also override the default behavior of proc-text-buffer so that it behaves like proc-text-buffer-q with the help of a connection time DataServer option PRGRS_QUOTE_PROCTEXT. For more information on DataServer (-Dsrv) options, see DataServer options.
*Define a special ODBC view on the data source to use as a buffer for the rows of results.
The following ABL procedure reads the database results from the stored procedure into the proc–text–buffer supplied by OpenEdge:
RUN STORED-PROC pcust (20, OUTPUT 0, OUTPUT 0).
FOR EACH proc-text-buffer:
  DISPLAY proc-text-buffer.
END.
CLOSE STORED-PROC pcust.
DISPLAY pcust.orders pcust.states.
The ABL-defined buffer, proc–text–buffer, has one character field named proc–text. The buffer accepts the returned database results, converts them to CHARACTER data type, and concatenates them into one string. The advantage of using the proc–text–buffer is that you do not have to worry about what kind of data the procedure returns. The buffer accepts any type of data, in any order. The disadvantage is that it is much more difficult to manipulate the data after you receive it. To act on anything but CHARACTER data, you must extract the data from the buffer and convert it to its original data type before you can use it.
Another benefit of the proc–text–buffer is that it holds the results from all of the SQL statements included in a stored procedure. However, a buffer that you create can hold the results of only one SQL statement.
This is the partial syntax for the DEFINE BUFFER statement that you use to create a buffer with the same characteristics of the proc–text–buffer:

Syntax

DEFINE BUFFER buffer-name FOR proc-text-buffer
For a complete description, see the DEFINE BUFFER entry in OpenEdge Development: ABL Reference.