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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

256<br />

Throws<br />

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

Notes • Before invoking getValue, you must test for the NULL condition by calling the<br />

<strong>SQL</strong>Cursor.wasNULL method. If the value returned is NULL, you must explicitly set the<br />

target variable in the stored procedure to NULL.<br />

• The getValue method returns a value from the result set identified by the number you<br />

specify in the fieldNum parameter. getValue returns the value as an object of the data type<br />

you specify in the fieldType parameter. Since getValue returns the result as an instance<br />

of class Object, you must explicitly cast your return value to the correct data type.<br />

• If the returned value is of data type CHARACTER, then getValue returns a Java String<br />

Object. You must declare a procedure variable of type String and explicitly cast the value<br />

returned by getValue to type String.<br />

Example This example illustrates testing for NULL and invoking the Java getValue method:<br />

Integer pvar_int = new Integer(0);<br />

String pvar_str = new String();<br />

<strong>SQL</strong>Cursor select_t1 = new <strong>SQL</strong>Cursor<br />

("select int_col, char_col from T1");<br />

Select_t1.open();<br />

Select_t1.fetch();<br />

while(select_t1.found())<br />

{<br />

// Assign values from the current row of the <strong>SQL</strong> result set<br />

// to the procedure variables. First check whether<br />

// the values fetched are null. If null then explicitly<br />

// set the procedure variables to null.<br />

}<br />

<strong>SQL</strong>Cursor.makeNULL<br />

Sets the value of an <strong>SQL</strong> statement’s input parameter to NULL. This method is common to the<br />

<strong>SQL</strong>Cursor, <strong>SQL</strong>IStatement, and <strong>SQL</strong>PStatement classes. This method is redundant with using<br />

the setParam method to set an <strong>SQL</strong> statement’s input parameter to NULL.<br />

Format<br />

Returns<br />

if ((select_t1.wasNULL(1)) == true)<br />

pvar_int = null;<br />

else<br />

pvar_int = (Integer)select_t1.getValue(1, INTEGER);<br />

if ((select_t1.wasNULL(2)) == true)<br />

pvar_str = null;<br />

else<br />

pvar_str = (String)select_t1.getValue(1, CHAR);<br />

public void makeNULL(int f)<br />

None

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

Saved successfully!

Ooh no, something went wrong!