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.

Loading result sets into temp-tables<br />

Interfacing with RDBMS stored procedures<br />

Enhancements implemented through changes to the RUN STORED-PROC statement allow you to<br />

retrieve result sets from a <strong>for</strong>eign data source and load each result set, <strong>for</strong> which a temp-table<br />

handle is defined, into its own temp-table. The LOAD_RESULT-INTO function enables data<br />

retrieved to be loaded into temp-tables where the data can then be manipulated, employing all<br />

characteristics inherent to temp-tables. The capability to load result sets into temp-tables is not<br />

limited by the parsing requirements associated with the proc-text-buffer nor the database<br />

dependencies associated with views.<br />

Temp-tables can provide data management capabilities associated with ABL directly to the<br />

result sets of a stored procedure, but completely independent of the <strong>for</strong>eign data source from<br />

which it was populated and/or derived. Temporary tables are effectively database tables in<br />

which <strong>OpenEdge</strong> stores data temporarily. Because temp-tables have the same support features<br />

that actual <strong>OpenEdge</strong> databases use, you can take advantage of almost all the <strong>OpenEdge</strong><br />

database features that do not require data persistence and multi-user access. For example, you<br />

can define indexes <strong>for</strong> fields in the temp-table. For more in<strong>for</strong>mation about temp-tables, see<br />

<strong>OpenEdge</strong> Getting Started: ABL Essentials.<br />

Example 3–13 shows how to use the RUN STORED-PROC statement with the LOAD-RESULT-INTO<br />

phrase with a single dynamic temp-table. It highlights the coding techniques discussed in the<br />

“Run Stored-Proc statement execution using the send-sql-statement option” section on<br />

page 3–11 and it introduces the dynamic temp-table topic further discussed in this section.<br />

DEFINE VARIABLE bhCustomer AS HANDLE NO-UNDO.<br />

DEFINE VARIABLE hBrowse AS HANDLE NO-UNDO.<br />

DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.<br />

DEFINE VARIABLE ttCustomer AS HANDLE NO-UNDO.<br />

DEFINE FRAME BrowseFrame WITH SIZE 80 BY 10.<br />

CREATE TEMP-TABLE ttCustomer.<br />

RUN STORED-PROC send-sql-statement LOAD-RESULT-INTO ttCustomer<br />

(“SELECT * from CUSTOMER”).<br />

bhCustomer = ttCustomer:DEFAULT-BUFFER-HANDLE.<br />

CREATE QUERY hQuery.<br />

hQuery:SET-BUFFERS (bhCustomer).<br />

DISPLAY ttCustomer:Name.<br />

hQuery:QUERY-PREPARE(“FOR EACH” + ttCustomer:Name).<br />

hQuery:QUERY-OPEN.<br />

CREATE BROWSE hBrowse ASSIGN<br />

ROW = 1<br />

COL = 1<br />

WIDTH = 79<br />

DOWN = 10<br />

FRAME = FRAME BrowseFrame:HANDLE<br />

QUERY = hQuery<br />

SENSITIVE = TRUE<br />

SEPARATORS = TRUE<br />

ROW-MARKERS = FALSE<br />

VISIBLE = TRUE.<br />

hBrowse:ADD-COLUMNS-FROM(bhCustomer).<br />

ENABLE ALL WITH FRAME BrowseFrame.<br />

WAIT-FOR CLOSE OF CURRENT-WINDOW.<br />

Example 3–13: RUN STORED-PROC statement with the LOAD-RESULT-INTO<br />

phrase<br />

3–21

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

Saved successfully!

Ooh no, something went wrong!