Calling PLSQL Functions in OAF by Callable Statement


Imagine that you have a fucntion wriiten. Now you have to call the Function and obtain a return type in OAF. This can be done by callable Statement

CallableStatement callableStatement = txn.createCallableStatement(“declare begin :outVariable := xx_function(:2); end;”,OADBTransaction.DEFAULT); //Refer to the Syntax where the String is a procedure

String outParamValue = null;
try
{
callableStatement.registerOutParameter(1, Types.VARCHAR); //First Bind Varible should give us out Parameter
callableStatement.setString(2, valuetobePassed); //Passing a variable to Second Variable
callableStatement.execute();
outParamValue = (callableStatement.getString(1)).toString();
System.out.println(“The Out Parameter Obtained from the Procedure is “+outParamValue);
}
catch (SQLException sqle)  //Be cautious that execute() throws an SQL Exception
{
System.out.println(“Exception occured”);
}

where the 1st parameter is String where you can use your Function
in 2nd parameter you will pass a number(OADBTransaction.DEFAULT-> Represents -1)

Thank you For Reading

About pacesettergraam

A good and realistic person

Posted on August 28, 2013, in OAF, Uncategorized and tagged , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: