String remarks = getString(resultSet, "REMARKS", false);
// get kind of procedure
Integer procedureType = getInteger(resultSet, "PROCEDURE_TYPE", false);
// create Stored Procedure object
StoredProcedure sp = factory.createStoredProcedure();
// ***************************
// *** DatabaseNamedObject ***
// ***************************
// set name
sp.setName(procedureName);
// set remarks
sp.setRemarks(remarks);
// TODO set extra properties
// sp.addExtraProperty (String key, Object value);
// ********************
// *** SchemaObject ***
// ********************
// set catalog
if ((procedureCatalog != null) && (procedureCatalog.trim().length() != 0)) {
// find catalog
Catalog catalog = database.findCatalogByName(procedureCatalog);
// set catalog
sp.setCatalog(catalog);
// warn if null
if (catalog == null) {
traceLog.debug(String.format("[Database %s] Unable to find catalog '%4$s' for the procedure %s (schema %s, catalog %s)",
database.getName(),
procedureName,
procedureSchema,
procedureCatalog));
}
// if fail is enabled
if (failOnError && (catalog == null)) {
throw new DatabaseMetaDataMethodException("Catalog name shall be provided", "populateStoredProcedure");
}
}
// set schema
if ((procedureSchema != null) && (procedureSchema.trim().length() != 0)) {
// find schema
Schema schema = database.findSchemaByName(procedureCatalog, procedureSchema);
// set schema
sp.setSchema(schema);
// warn if null
if (schema == null) {
traceLog.debug(String.format("[Database %s] Unable to find schema '%3$s' for the procedure %s (schema %s, catalog %s)",
database.getName(),
procedureName,
procedureSchema,
procedureCatalog));
}
// if fail is enabled
if (failOnError && (schema == null)) {
throw new DatabaseMetaDataMethodException("Schema name shall be provided", "populateStoredProcedure");
}
}
// ***********************
// *** StoredProcedure ***
// ***********************
// set sp result type
sp.setResultType(getStoredProcedureResultType(procedureType));
// add SP to the list
database.addStoredProcedure(sp);
// log