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:
- what is the right way to list out all procedures and functions that are user-defined and in-built (along with the most used)?
- what is the right way to execute procedures and functions?
- what is wrong with the way I am fetching and executing the procedures?
- How can I differentiate the overloaded procedures and functions and execute them?