Calling Database Procedures and Function From OAF
Calling Database Procedures and Function From OAF
Calling Database Procedures and Function From OAF
According to Oracle Standards whenever it is possible we should use View Objects for
Database operation but in some situations we have to call PL/SQL Procedures and
Functions using JDBC.
1. Create a JDBC CallableStatement with the PL/SQL block containing the stored
procedure invocation
2. Register OUT Parameter if any
3. Bind any variables.
4. Execute the statement.
5. Retrieve the values of any OUT parameters if any
6. Close the statement
If we are using PL/SQL Procedure, then String that we will pass to callable statement
will be in following form:
“BEGIN Package_name.procedure_name(:1,:2) END;” where :1 and :2 are Parameters
which may be either IN or OUT Parameters.
Ex:
1.((OracleCallableStatement)cs.registerOutParameter(1, Types.VARCHAR, 0,
2000);
Bind IN Parameters:
To bind in parameters we can use following statement: cs.setString(1, value); where
setString can be replaced by SetNumber/SetDate as per your requirement.
Example:
1.messageBuffer = cs.getString(1);
Close Statement:
To close the statement we can use close()method of callable statement
Example 1.
01.import java.sql.CallableStatement;
02.import java.sql.SQLException;
03.import java.sql.Types;
04....
05.String outParamValue;
06.OADBTransaction txn = getDBTransaction();
07.CallableStatement cs =
08.txn.createCallableStatement("begin Test_Package.test_prc(:1, :2);
09.end;");
10.try
11.{
12.((OracleCallableStatement)cs.registerOutParameter(2, Types.VARCHAR, 0,
2000);
13.cs.setString(1, “Reetesh”);
14.cs.execute();
15.outParamValue = cs.getString(1);
16.cs.close();
17.}
18.catch (SQLException sqle)
19.{
20.cs.close();
21.}
01.import java.sql.CallableStatement;
02.import java.sql.SQLException;
03.import java.sql.Types;
04....
05.String outParamValue;
06.OADBTransaction txn = getDBTransaction();
07.CallableStatement cs =
08.txn.createCallableStatement("begin :1 := Test_Package.test_func(:2);
09.end;");
10.try
11.{
12.((OracleCallableStatement)cs.registerOutParameter(1, Types.VARCHAR, 0,
2000);
13.cs.setString(1,”Reetesh”);
14.cs.execute();
15.outParamValue = cs.getString(1);
16.cs.close();
17.}
18.catch (SQLException sqle)
19.{
20.cs.close();
21.}
There was a requirement with one of my client to open an OAF page from workflow
email notification. In R12 below error will occur if you try to open an OAF Page URL
link directly.
You are trying to access a page that is no longer active.
- The referring page may have come from a previous session. Please select Home
to Proceed.
Note: When you call a standard page this error won't appear. This happens only when
you try to open a custom page.
1).Open the custom page in Jdev and select the PageLayoutRN. In the property
inspector set the Security Mode to selfSecured.
Eg: ${oa.FunctionSecurity.XXCUSTPG}
Note: Your user id should have access to the custom page function.
3).In your workflow procedure generate the OA page URL with the below function and
set the workflow attribute with the generated URL.
Now you should be able to open the OAF page from workflow email notification.