Product Documentation

FairCom Java & .NET Stored Procedures

Previous Topic

Next Topic

SQLCursor.getParam

When a procedure is called from another procedure, this method returns the value of the specified OUT/INOUT parameter of the called procedure as a Java object. This returned object must be typecasted to the appropriate type. This method is common to the SQLCursor, SQLIStatement, and SQLPStatement classes.

Format

public Object getParam(int field, short dType)

Returns

Returns the Object specified by the field value.

Parameters

field

An integer that specifies which argument value of the called procedure is to be returned (1 denotes the first parameter, 2 denotes the second, and so on).

If the specified parameter does not exist, FairCom DB SQL returns an error:

(error(-20145): Invalid field reference.)

dType

The expected data type of the returning parameter.

Throws

DhSQLException

Example


CREATE PROCEDURE swap_proc(IN param1 INTEGER,

OUT param2 INTEGER,

INOUT param3 INTEGER

)

BEGIN

param2 = param3;

param3 = param1;

END


CREATE PROCEDURE call_swap_proc()

BEGIN

Integer val1 = new Integer(10);

Integer val2;

Integer val3 = new Integer(20);

SQLCursor tmp_cur = new SQLCursor("CALL swap_proc(?,?,?)");

tmp_cur.registerOutParam(2, INTEGER);

tmp_cur.registerOutParam(3, INTEGER);

tmp_cur.setParam(1, val1);

tmp_cur.setParam(3, val3);

tmp_cur.open();

val2 = (Integer)tmp_cur.getParam(2, INTEGER);

val3 = (Integer)tmp_cur.getParam(3, INTEGER);

// process the val2 and val3

- - -

tmp_cur.close();

END

TOCIndex