23.10.2012 Views

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

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.

<strong>SQL</strong>Cursor<br />

CREATE PROCEDURE get_sal2 ()<br />

RESULT (<br />

empname CHAR(20),<br />

empsal NUMERIC,<br />

)<br />

BEGIN<br />

String ename = new String (20) ;<br />

BigDecimal esal = new BigDecimal () ;<br />

<strong>SQL</strong>Cursor empcursor = new <strong>SQL</strong>Cursor (<br />

"SELECT name, sal FROM emp " ) ;<br />

END<br />

Java Class <strong>Reference</strong><br />

Allows rows of data to be retrieved from a database or another stored procedure’s result set.<br />

Constructors<br />

<strong>SQL</strong>Cursor (String statement)<br />

Parameters<br />

statement<br />

Generates a result set. Enclose the <strong>SQL</strong> statement in double quotes. The <strong>SQL</strong> statement is<br />

either a SELECT or CALL statement.<br />

Notes • A SELECT statement queries the database and returns data that meets the criteria specified<br />

by the query expression in the SELECT statement.<br />

• A CALL statement invokes another stored procedure that returns a result set specified by<br />

the RESULT clause of the CREATE PROCEDURE statement.<br />

Throws<br />

empcursor.Open () ;<br />

do<br />

{<br />

empcursor.Fetch ();<br />

if (empcursor.found ())<br />

{<br />

empcursor.getValue (1, ename);<br />

empcursor.getValue (2, esal);<br />

<strong>SQL</strong>ResultSet.Set (1, ename);<br />

<strong>SQL</strong>ResultSet.Set (2, esal);<br />

<strong>SQL</strong>ResultSet.Insert ();<br />

}<br />

} while (empcursor.found ()) ;<br />

empcursor.close () ;<br />

Dh<strong>SQL</strong>Exception<br />

Examples The following excerpt from a stored procedure instantiates an <strong>SQL</strong>Cursor object called<br />

cust_cursor that retrieves data from a database table:<br />

251

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

Saved successfully!

Ooh no, something went wrong!