Product Documentation

FairCom Java & .NET Stored Procedures

Previous Topic

Next Topic

SQLIStatement.getParam

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

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 exists, 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);

SQLIStatement istmt = new SQLIStatement("CALL swap_proc(?,?,?)");

istmt.registerOutParam(2, INTEGER);

istmt.registerOutParam(3, INTEGER);

istmt.setParam(1, val1);

istmt.setParam(3, val3);

istmt.execute();

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

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

// process the val2 and val3

END

TOCIndex