Class StoredProcedure

java.lang.Object
org.apache.openjpa.jdbc.sql.StoredProcedure

public class StoredProcedure extends Object
Holds metadata about a Database Stored Procedure. This is different than MultiQueryMetaData which holds the metadata about what the user has specified.
An instance of this class can be constructed either by reading from database meta data or by programatic assignment. If an instance if created programmatically, then its SQL body or parameters can be added.
This class can generate the SQL statement to create, drop or delete this procedure.
Author:
Pinaki Poddar
  • Constructor Details

    • StoredProcedure

      public StoredProcedure(String name)
      Create a procedure of the given name.
    • StoredProcedure

      public StoredProcedure(ResultSet rs) throws SQLException
      
              1. PROCEDURE_CAT - String - the procedure catalog name
              2. PROCEDURE_SCHEM - String - the procedure schema name (possibly null)
              3. PROCEDURE_NAME - String - the procedure name
              4. COLUMN_NAME - String - the name of the column
              5. COLUMN_TYPE - short - the kind of column or parameter, as follows:
                              DatabaseMetaData.procedureColumnUnknown - type unknown
                              DatabaseMetaData.procedureColumnIn - an IN parameter
                              DatabaseMetaData.procedureColumnInOut - an INOUT parameter
                              DatabaseMetaData.procedureColumnOut - an OUT parameter
                              DatabaseMetaData.procedureColumnReturn - a return value
                              DatabaseMetaData.procedureReturnsResult - a result column in a result set
              6. DATA_TYPE - int - the SQL type of the data, as in java.sql.Types
              7. TYPE_NAME - String - the SQL type name, for a UDT it is fully qualified
              8. PRECISION - int - the precision
              9. LENGTH - int - the length of the data in bytes
              10.SCALE - short - the scale for numeric types
              11.RADIX - short - the Radix for numeric data (typically 2 or 10)
              12.NULLABLE - short - can the data contain null:
                              DatabaseMetaData.procedureNoNulls - NULLs not permitted
                              DatabaseMetaData.procedureNullable - NULLs are permitted
                              DatabaseMetaData.procedureNullableUnknown - NULL status unknown
              13.REMARKS - String - an explanatory comment about the data item
       
      Throws:
      SQLException
  • Method Details

    • setCatalog

      public void setCatalog(DBIdentifier catalog)
    • setSchema

      public void setSchema(DBIdentifier schema)
    • setName

      public void setName(String name)
    • getInColumns

      public Column[] getInColumns()
    • getInOutColumns

      public Column[] getInOutColumns()
    • getOutColumns

      public Column[] getOutColumns()
    • getReturnColumns

      public Column[] getReturnColumns()
    • getResultColumns

      public Column[] getResultColumns()
    • getColumns

      public Column[] getColumns()
    • getName

      public String getName()
      Gets the name of this procedure.
    • addParameter

      public StoredProcedure addParameter(String var, String typeName)
      Adds an IN parameter of the given name and type.
      Parameters:
      var - name of the variable
      typeName - name of the SQL type e.g. VARCAR(32)
      Returns:
      this procedure instance
    • addParameter

      public StoredProcedure addParameter(StoredProcedure.PARAM param, String var, String typeName)
      Adds the given parameter declaration.
      Parameters:
      param - type of parameter.
      var - name of the variable
      typeName - name of the SQL type e.g. VARCAR(32)
      Returns:
      this procedure instance
    • setLanguage

      public StoredProcedure setLanguage(String language)
    • getCreateSQL

      public String getCreateSQL()
      Gets the SQL for creating this procedure.
    • getDropSQL

      public String getDropSQL()
      Gets the SQL for dropping this procedure.
    • getCallSQL

      public String getCallSQL()
      Gets the SQL for calling this procedure.
    • setSQL

      public StoredProcedure setSQL(StoredProcedure.SQL sql)
      Adds a read SQL statement via an external method.
    • setParameterStyle

      public StoredProcedure setParameterStyle(String lang)
      Sets the language whose parameter passing convention will be used to pass paramater values.
      Parameters:
      lang -
      Returns:
    • setExternalName

      public StoredProcedure setExternalName(Class<?> cls, String method, Class<?>... paramTypes)
    • setResult

      public StoredProcedure setResult(int i)
    • setResult

      public StoredProcedure setResult(int i, boolean dynamic)
    • toString

      public String toString()
      Overrides:
      toString in class Object