Assessing result sets obtained by defining a view as buffer technique
- Last Updated: January 17, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Assessing result sets obtained by defining a view as buffer technique
The buffer in the previous procedure defines two returned values
for a stored procedure—an INTEGER and a CHARACTER value—in
that order. If the data types do not match those returned by the
stored procedure, the procedure returns more than two values, or
returns the values in a different order than you specified, you receive
a run-time error.
The easiest way to create a buffer that accepts data from stored
procedures is to use the text of the SQL SELECT statement
from the stored procedure. This ensures that you define your data
types correctly and in the correct order. Use a native process such
as sp_helptext to view the stored procedure from
a MS SQL Server, or view procedures in the system tables.
The examples in this section do not use the supplied proc-text-buffer buffer.
Instead, they show how to define formatted buffers by creating views
in the data source, using the following syntax:
Syntax
|
Views created in your MS SQL Server data source
The following code examples show two views created in your MS SQL Server data source that you can use as buffers to store the results from the stored procedure pcust.
|
|
Result set of pcust - typed buffers
The following code example shows ABL procedure results of the previous stored procedure
pcust as it is written into the new buffers pcust_orders
and pcust_states.
|
Because two different buffers have been defined, the returned values maintain their data
types instead of being converted to character strings and stored in the OpenEdge-defined
buffer proc-text-buffer. You can then use the returned values in
calculations without first converting them back to their original data types. In addition,
the two separate buffers make your output look cleaner, allowing ABL to build a new default
frame for the two different types of output. Reading your results into an explicitly defined
buffer also allows you to manipulate the data just as you would manipulate data from an
OpenEdge database; for example, with Frame phrases and FORM statements.
Procedure handles
The following example accesses the stored procedure pcust twice; procedure
handles (through the PROC-HANDLE function) identify the different results
from your data source.
|
The results look the same as in the first two examples. However, because you are running a stored procedure twice, ABL uses the procedure handles to identify the different instances. If you have more than one stored procedure open simultaneously in your application, you must explicitly define procedure handles for each.
Joining stored procedure results with other database tables
The following example shows how to use standard OpenEdge syntax to join the results from a stored procedure with other tables in the database.
|
The example code joins the order information returned from the stored procedure with the
orderline information in the same database.