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 />

Note: The ABL QUOTER function can be useful <strong>for</strong> quoting values or handling<br />

embedded quotes when building <strong>SQL</strong> statements that will be passed into<br />

stored procedures with the send-sql-statement option.<br />

Assessing result sets obtained from the proc-text-buffer technique<br />

The advantage of using the proc–text–buffer is that you do not have to worry about<br />

what kind of data the procedure returns. The buffer accepts any type of data, in any<br />

order, and converts it to the character equivalent. Another benefit of the<br />

proc–text–buffer is that it can be used to hold the results from all of the <strong>SQL</strong><br />

statements included in a stored procedure. However, a buffer that you create can hold<br />

the results of only one results set record <strong>for</strong>m one result set at a time.<br />

However, a disadvantage in using the proc-text-buffer technique is that it is much<br />

more difficult to manipulate the data after you receive it as it requires parsing the data.<br />

To act on anything but CHARACTER data, you must extract the data from the buffer and<br />

convert it to its original data type be<strong>for</strong>e you can use it.<br />

Defining a view to use as a buffer<br />

As an alternative to using the <strong>OpenEdge</strong> buffer proc–text–buffer definition, you can<br />

define a view in the data source that can serve as a buffer allowing you to retrieve<br />

database results in their original data types. However, keep in mind that using views<br />

creates a database dependency beyond the stored procedure itself.<br />

Technique to define a view to use as a buffer<br />

While a stored procedure can include multiple <strong>SQL</strong> statements, a buffer that you define<br />

contains the <strong>for</strong>mat of only a single results set. You need to define multiple views to<br />

accommodate multiple results sets.<br />

To define a buffer:<br />

1. Define a view in the MS <strong>SQL</strong> <strong>Server</strong> data source with the following characteristics:<br />

• The naming convention _BUFFER_buffername<br />

• The same number of columns and data types that the stored procedure<br />

returns in the results set<br />

• The columns in the order that the stored procedure returns them<br />

For example, to return two columns with two types of values, an integer and a<br />

character string, use a <strong>SQL</strong> utility to define the following view in the data source:<br />

CREATE VIEW _BUFFER_custlist AS SELECT customer.cust_num,<br />

customer.name FROM customer WHERE 1 = 0<br />

GO<br />

Notice that these views are defined to ensure that they never return any results.<br />

This helps to indicate that the purpose of the view is its buffer content and not its<br />

<strong>SQL</strong> capabilities. It is not necessary to define views that you will use as buffers<br />

this way, but it does allow you to distinguish quickly between views and buffers.<br />

<strong>OpenEdge</strong> <strong>Data</strong> <strong>Management</strong>: <strong>Data</strong><strong>Server</strong> <strong>for</strong> <strong>Microsoft</strong> <strong>SQL</strong> <strong>Server</strong> 137

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

Saved successfully!

Ooh no, something went wrong!