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.

Details about a dynamic temp-table in an unprepared state<br />

Interfacing with RDBMS stored procedures<br />

A dynamic temp-table is considered to be in an unprepared state after the first definitional<br />

method is called until the temp-table is prepared. If a clear dynamic temp-table handle is passed,<br />

the <strong>Data</strong><strong>Server</strong> populates the temp-table schema based on the result-set schema and prepares the<br />

temp-table. A clear dynamic temp-table is a table that is in an unprepared state where<br />

definitional methods have not yet been called. The <strong>Data</strong><strong>Server</strong> then executes the temp-table<br />

handle: ADD-NEW-FIELD (field name, data type) internally <strong>for</strong> each one of the columns of the<br />

result set. If a column in the result set from the <strong>for</strong>eign schema does not have a name (<strong>for</strong><br />

example, an array element field or a <strong>SQL</strong>-derived field), the <strong>Data</strong><strong>Server</strong> assigns a name to it<br />

based on the column position on the row.<br />

For example, if you run the following statement, then the temp-table contains these columns:<br />

• Column 1<br />

• Cust_num<br />

• Name<br />

• Column 4<br />

/* */<br />

SELECT “mytag,” cust_num, name, (salary * 0.10) FROM <br />

The data type associated with each column follows the mapping rules that exist between<br />

<strong>OpenEdge</strong> and the <strong>for</strong>eign data source’s data types. For more in<strong>for</strong>mation about data types and<br />

default mapping, see Chapter 2, “Initial Programming Considerations.”<br />

Note: Since a stored procedure can return multiple result sets, the <strong>Data</strong><strong>Server</strong> prepares the<br />

temp-table as “result” where is the result-set sequence number that<br />

corresponds to its element position in the temp table handle array, starting with 1.<br />

There<strong>for</strong>e, if there are 3 result sets and 3 clear dynamic temp-tables are passed, the<br />

temp-tables are called result1, result2, and result3.<br />

Note the following error conditions as they specifically apply to a dynamic temp-table:<br />

• If an error occurs during the schema population or during the prepare of a temp-table, the<br />

<strong>Data</strong><strong>Server</strong> raises an error condition.<br />

• The dynamic temp-table must be either already prepared or clear with no defined fields in<br />

it. If fields have already been added to a dynamic temp-table be<strong>for</strong>e the RUN STORED-PROC<br />

statement is executed and the temp-table is not prepared, the <strong>Data</strong>Sever raises an error<br />

condition due to the invalid state of the temp-table.<br />

3–25

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

Saved successfully!

Ooh no, something went wrong!