use of org.h2.engine.Procedure in project h2database by h2database.
the class JdbcDatabaseMetaData method getProcedures.
/**
* Gets the list of procedures. The result set is sorted by PROCEDURE_SCHEM,
* PROCEDURE_NAME, and NUM_INPUT_PARAMS. There are potentially multiple
* procedures with the same name, each with a different number of input
* parameters.
*
* <ol>
* <li>PROCEDURE_CAT (String) catalog</li>
* <li>PROCEDURE_SCHEM (String) schema</li>
* <li>PROCEDURE_NAME (String) name</li>
* <li>NUM_INPUT_PARAMS (int) the number of arguments</li>
* <li>NUM_OUTPUT_PARAMS (int) for future use, always 0</li>
* <li>NUM_RESULT_SETS (int) for future use, always 0</li>
* <li>REMARKS (String) description</li>
* <li>PROCEDURE_TYPE (short) if this procedure returns a result
* (procedureNoResult or procedureReturnsResult)</li>
* <li>SPECIFIC_NAME (String) name</li>
* </ol>
*
* @param catalogPattern null or the catalog name
* @param schemaPattern null (to get all objects) or a schema name
* (uppercase for unquoted names)
* @param procedureNamePattern the procedure name pattern
* @return the procedures
* @throws SQLException if the connection is closed
*/
@Override
public ResultSet getProcedures(String catalogPattern, String schemaPattern, String procedureNamePattern) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("getProcedures(" + quote(catalogPattern) + ", " + quote(schemaPattern) + ", " + quote(procedureNamePattern) + ");");
}
checkClosed();
PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " + "ALIAS_CATALOG PROCEDURE_CAT, " + "ALIAS_SCHEMA PROCEDURE_SCHEM, " + "ALIAS_NAME PROCEDURE_NAME, " + "COLUMN_COUNT NUM_INPUT_PARAMS, " + "ZERO() NUM_OUTPUT_PARAMS, " + "ZERO() NUM_RESULT_SETS, " + "REMARKS, " + "RETURNS_RESULT PROCEDURE_TYPE, " + "ALIAS_NAME SPECIFIC_NAME " + "FROM INFORMATION_SCHEMA.FUNCTION_ALIASES " + "WHERE ALIAS_CATALOG LIKE ? ESCAPE ? " + "AND ALIAS_SCHEMA LIKE ? ESCAPE ? " + "AND ALIAS_NAME LIKE ? ESCAPE ? " + "ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME, NUM_INPUT_PARAMS");
prep.setString(1, getCatalogPattern(catalogPattern));
prep.setString(2, "\\");
prep.setString(3, getSchemaPattern(schemaPattern));
prep.setString(4, "\\");
prep.setString(5, getPattern(procedureNamePattern));
prep.setString(6, "\\");
return prep.executeQuery();
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of org.h2.engine.Procedure in project h2database by h2database.
the class JdbcDatabaseMetaData method getProcedureColumns.
/**
* Gets the list of procedure columns. The result set is sorted by
* PROCEDURE_SCHEM, PROCEDURE_NAME, NUM_INPUT_PARAMS, and POS.
* There are potentially multiple procedures with the same name, each with a
* different number of input parameters.
*
* <ol>
* <li>PROCEDURE_CAT (String) catalog</li>
* <li>PROCEDURE_SCHEM (String) schema</li>
* <li>PROCEDURE_NAME (String) name</li>
* <li>COLUMN_NAME (String) column name</li>
* <li>COLUMN_TYPE (short) column type
* (always DatabaseMetaData.procedureColumnIn)</li>
* <li>DATA_TYPE (short) sql type</li>
* <li>TYPE_NAME (String) type name</li>
* <li>PRECISION (int) precision</li>
* <li>LENGTH (int) length</li>
* <li>SCALE (short) scale</li>
* <li>RADIX (int) always 10</li>
* <li>NULLABLE (short) nullable
* (DatabaseMetaData.columnNoNulls for primitive data types,
* DatabaseMetaData.columnNullable otherwise)</li>
* <li>REMARKS (String) description</li>
* <li>COLUMN_DEF (String) always null</li>
* <li>SQL_DATA_TYPE (int) for future use, always 0</li>
* <li>SQL_DATETIME_SUB (int) for future use, always 0</li>
* <li>CHAR_OCTET_LENGTH (int) always null</li>
* <li>ORDINAL_POSITION (int) the parameter index
* starting from 1 (0 is the return value)</li>
* <li>IS_NULLABLE (String) always "YES"</li>
* <li>SPECIFIC_NAME (String) name</li>
* </ol>
*
* @param catalogPattern null or the catalog name
* @param schemaPattern null (to get all objects) or a schema name
* (uppercase for unquoted names)
* @param procedureNamePattern the procedure name pattern
* @param columnNamePattern the procedure name pattern
* @return the procedure columns
* @throws SQLException if the connection is closed
*/
@Override
public ResultSet getProcedureColumns(String catalogPattern, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("getProcedureColumns(" + quote(catalogPattern) + ", " + quote(schemaPattern) + ", " + quote(procedureNamePattern) + ", " + quote(columnNamePattern) + ");");
}
checkClosed();
PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " + "ALIAS_CATALOG PROCEDURE_CAT, " + "ALIAS_SCHEMA PROCEDURE_SCHEM, " + "ALIAS_NAME PROCEDURE_NAME, " + "COLUMN_NAME, " + "COLUMN_TYPE, " + "DATA_TYPE, " + "TYPE_NAME, " + "PRECISION, " + "PRECISION LENGTH, " + "SCALE, " + "RADIX, " + "NULLABLE, " + "REMARKS, " + "COLUMN_DEFAULT COLUMN_DEF, " + "ZERO() SQL_DATA_TYPE, " + "ZERO() SQL_DATETIME_SUB, " + "ZERO() CHAR_OCTET_LENGTH, " + "POS ORDINAL_POSITION, " + "? IS_NULLABLE, " + "ALIAS_NAME SPECIFIC_NAME " + "FROM INFORMATION_SCHEMA.FUNCTION_COLUMNS " + "WHERE ALIAS_CATALOG LIKE ? ESCAPE ? " + "AND ALIAS_SCHEMA LIKE ? ESCAPE ? " + "AND ALIAS_NAME LIKE ? ESCAPE ? " + "AND COLUMN_NAME LIKE ? ESCAPE ? " + "ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME, ORDINAL_POSITION");
prep.setString(1, "YES");
prep.setString(2, getCatalogPattern(catalogPattern));
prep.setString(3, "\\");
prep.setString(4, getSchemaPattern(schemaPattern));
prep.setString(5, "\\");
prep.setString(6, getPattern(procedureNamePattern));
prep.setString(7, "\\");
prep.setString(8, getPattern(columnNamePattern));
prep.setString(9, "\\");
return prep.executeQuery();
} catch (Exception e) {
throw logAndConvert(e);
}
}
Aggregations