Package org.apache.openjpa.jdbc.sql
Class StoredProcedure
- java.lang.Object
-
- org.apache.openjpa.jdbc.sql.StoredProcedure
-
public class StoredProcedure extends java.lang.Object
Holds metadata about a Database Stored Procedure. This is different thanMultiQueryMetaData
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StoredProcedure.PARAM
An enumeration on type of parameter for a Stored Procedure.static class
StoredProcedure.SQL
-
Constructor Summary
Constructors Constructor Description StoredProcedure(java.lang.String name)
Create a procedure of the given name.StoredProcedure(java.sql.ResultSet rs)
1.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StoredProcedure
addParameter(java.lang.String var, java.lang.String typeName)
Adds anIN
parameter of the given name and type.StoredProcedure
addParameter(StoredProcedure.PARAM param, java.lang.String var, java.lang.String typeName)
Adds the given parameter declaration.java.lang.String
getCallSQL()
Gets the SQL for calling this procedure.Column[]
getColumns()
java.lang.String
getCreateSQL()
Gets the SQL for creating this procedure.java.lang.String
getDropSQL()
Gets the SQL for dropping this procedure.Column[]
getInColumns()
Column[]
getInOutColumns()
java.lang.String
getName()
Gets the name of this procedure.Column[]
getOutColumns()
Column[]
getResultColumns()
Column[]
getReturnColumns()
void
setCatalog(DBIdentifier catalog)
StoredProcedure
setExternalName(java.lang.Class<?> cls, java.lang.String method, java.lang.Class<?>... paramTypes)
StoredProcedure
setLanguage(java.lang.String language)
void
setName(java.lang.String name)
StoredProcedure
setParameterStyle(java.lang.String lang)
Sets the language whose parameter passing convention will be used to pass paramater values.StoredProcedure
setResult(int i)
StoredProcedure
setResult(int i, boolean dynamic)
void
setSchema(DBIdentifier schema)
StoredProcedure
setSQL(StoredProcedure.SQL sql)
Adds a read SQL statement via an external method.java.lang.String
toString()
-
-
-
Constructor Detail
-
StoredProcedure
public StoredProcedure(java.lang.String name)
Create a procedure of the given name.
-
StoredProcedure
public StoredProcedure(java.sql.ResultSet rs) throws java.sql.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:
java.sql.SQLException
-
-
Method Detail
-
setCatalog
public void setCatalog(DBIdentifier catalog)
-
setSchema
public void setSchema(DBIdentifier schema)
-
setName
public void setName(java.lang.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 java.lang.String getName()
Gets the name of this procedure.
-
addParameter
public StoredProcedure addParameter(java.lang.String var, java.lang.String typeName)
Adds anIN
parameter of the given name and type.- Parameters:
var
- name of the variabletypeName
- name of the SQL type e.g.VARCAR(32)
- Returns:
- this procedure instance
-
addParameter
public StoredProcedure addParameter(StoredProcedure.PARAM param, java.lang.String var, java.lang.String typeName)
Adds the given parameter declaration.- Parameters:
param
- type of parameter.var
- name of the variabletypeName
- name of the SQL type e.g.VARCAR(32)
- Returns:
- this procedure instance
-
setLanguage
public StoredProcedure setLanguage(java.lang.String language)
-
getCreateSQL
public java.lang.String getCreateSQL()
Gets the SQL for creating this procedure.
-
getDropSQL
public java.lang.String getDropSQL()
Gets the SQL for dropping this procedure.
-
getCallSQL
public java.lang.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(java.lang.String lang)
Sets the language whose parameter passing convention will be used to pass paramater values.- Parameters:
lang
-- Returns:
-
setExternalName
public StoredProcedure setExternalName(java.lang.Class<?> cls, java.lang.String method, java.lang.Class<?>... paramTypes)
-
setResult
public StoredProcedure setResult(int i)
-
setResult
public StoredProcedure setResult(int i, boolean dynamic)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-