Sunday, August 18, 2019

How to call callable statement in OAF ?

Callable statement is used to call PLSQL Statements.

We need to use a Callable Statement to call either a function or a procedure from OAF.

Here are the steps to call a PL/SQL procedure:

Create a CallableStatement with the PL/SQL block of code to call the stored procedure.
Bind input and output variable
Execute CallableStatement
Capture OUT parameters
Close the CallableStatement statement

import java.sql.CallableStatement;
import java.sql.Types;
import oracle.apps.fnd.framework.server.OADBTransaction;

public void callProcedure() {

    String lkpCode = "XX_VAL_LIST_LKP";
    String lkpMeaning = "XX Lkp Meaning";

    CallableStatement callableStatement = 
        getOADBTransaction().createCallableStatement("begin  xx_lkp_details_pkg.list_lkp(:1,:2,:3); end;", OADBTransaction.DEFAULT);

    try {

        callableStatement.setString(1, lkpCode);
        callableStatement.setString(2, lkpMeaning);

        //registering out parameter
        callableStatement.registerOutParameter(3, Types.VARCHAR);

        callableStatement.execute();

        String tagValue = callableStatement.getString(3);

        if (tagValue != null) {

            System.out.println("Tag value: " + tagValue);

        }

    } catch (Exception e) {

        System.out.println(" XX in Catch Block of callableStatement: " +
                           e.getMessage());
    }
}

No comments:

Post a Comment

AME (Approval Management Engine)

AME (Approval Management Engine) : AME Stands for Oracle Approval Management Engine. AME is a self service web application that enables...