Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

All In-Built Procedures and Functions are not returned by getProcedures method even it is returning which are not working.

Vinay SharmaMay 14 2024 — edited May 14 2024

Hi all,
while using the getProcedures() method I am getting some procedures that are throwing errors : do not exist also it is not visible in UI. I also tried it by calling it with schemaName.ProcedureName but it still throws the error.
I have also seen that it does not return generic procedures like CONCAT, TO_CHAR, and many more which are generic and most used. Below is the POC I am using to fetch the procedure and call it

// method for listing procedures and schema of procedure
private static void listProcedureUsingMethod() throws SQLException {
Connection con = DriverManager.getConnection(urlQa, usernameQa, passwordQa);
DatabaseMetaData metaData = con.getMetaData();
System.out.println(metaData.getSchemas());
try (ResultSet resultSet = metaData.getFunctions(null, null, null)) {
while (resultSet.next()) {
String procedureName = resultSet.getString("PROCEDURE_NAME"); // index 3
String procedureType = resultSet.getString("PROCEDURE_SCHEM"); // index 8
System.out.println("Procedure Name: " + procedureName);
System.out.println("Procedure Type: " + procedureType); 
}
}
}

// method for executing procedure
public static void callStoredProcedure(String procedureName, String inputParameter) {
try (Connection connection = DriverManager.getConnection(urlQa, usernameQa, passwordQa)) {
try (CallableStatement callableStatement = connection.prepareCall("{call " + procedureName + "(?)}")) {
callableStatement.setString(1, inputParameter);
callableStatement.execute();
}
} catch (SQLException e) {
e.printStackTrace();
}
}

here, the Procedure name is passed in format = schemaName.ProcedureName.

Questions:

  1. what is the right way to list out all procedures and functions that are user-defined and in-built (along with the most used)?
  2. what is the right way to execute procedures and functions?
  3. what is wrong with the way I am fetching and executing the procedures?
  4. How can I differentiate the overloaded procedures and functions and execute them?
Comments
Post Details
Added on May 14 2024
0 comments
229 views