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–18<br />

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

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

anything but CHARACTER data, you must extract the data from the buffer and convert it to its<br />

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 define a<br />

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

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

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

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

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 returns in the<br />

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

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. This helps<br />

to indicate that the purpose of the view is its buffer content and not its <strong>SQL</strong> capabilities. It<br />

is not necessary to define views that you will use as buffers this way, but it does allow you<br />

to distinguish quickly between views and buffers.<br />

2. Update your schema image using the Update/Add Table Definitions <strong>Data</strong><strong>Server</strong> utility.<br />

The utility adds the view to the list of accessible objects in the schema holder. The<br />

<strong>Data</strong><strong>Server</strong> defines the view as a buffer that <strong>OpenEdge</strong> can use. (See the “Updating a<br />

schema holder” section on page 7–11 <strong>for</strong> instructions on using this utility.)<br />

Assessing result sets obtained by defining a view as buffer technique<br />

The buffer in the previous procedure defines two returned values <strong>for</strong> a stored procedure—an<br />

INTEGER and a CHARACTER value—in that order. If the data types do not match those returned by<br />

the stored procedure, the procedure returns more than two values, or returns the values in a<br />

different order than you specified, you receive a run-time error.

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

Saved successfully!

Ooh no, something went wrong!