Top Description Fields Constructors Methods
com.ziclix.python.sql

public Class Procedure

extends Object
Class Inheritance
Known Direct Subclasses
com.ziclix.python.sql.procedure.SQLServerProcedure
Imports
org.python.core.Py, .PyInteger, .PyList, .PyObject, .PyString, java.sql.CallableStatement, .DatabaseMetaData, .SQLException, java.util.BitSet

This class provides the necessary functionality to call stored procedures. It handles managing the database metadata and binding the appropriate parameters.
Author
brian zimmer

Field Summary

Modifier and TypeField and Description
protected static final int
COLUMN_TYPE

Field COLUMN_TYPE

protected PyObject
columns

Field columns

protected PyCursor
cursor

Field cursor

protected static final int
DATA_TYPE

Field DATA_TYPE

protected static final int
DATA_TYPE_NAME

Field DATA_TYPE_NAME

protected BitSet
inputSet

Field inputSet

protected static final int
LENGTH

Field LENGTH

protected static final int
NAME

Field NAME

protected static final int
NULLABLE

Field NULLABLE

protected static final int
PRECISION

Field PRECISION

protected PyObject
procedureCatalog

Field procedureCatalog

protected PyObject
procedureName

Field procedureName

protected PyObject
procedureSchema

Field procedureSchema

protected static final int
SCALE

Field SCALE

Constructor Summary

AccessConstructor and Description
public
Procedure(PyCursor
cursor an open cursor
cursor
,
PyObject
name a string or tuple representing the name
name
)

Constructor Procedure

Method Summary

Modifier and TypeMethod and Description
protected void
fetchColumns()

Get the columns for the stored procedure.

protected PyObject

Returns:

the default value (the empty string)
getDefault
()

The value for a missing schema or catalog.

protected String
getProcedureName()

Construct a procedure name for the relevant schema and catalog information.

public boolean

Returns:

true if the column is an input, false otherwise
isInput
(int
JDBC indexed column index (1, 2, ...)
index
)

This method determines whether the param at the specified index is an IN or INOUT param for a stored procedure.

public void
normalizeInput(PyObject
a non-None list of params
params
,
PyObject
a dictionary of bindings
bindings
)

Prepare the binding dictionary with the correct datatypes.

public CallableStatement

Returns:

CallableStatement
prepareCall
()

Prepares the statement and registers the OUT/INOUT parameters (if any).

public CallableStatement

Returns:

CallableStatement
prepareCall
(PyObject
the value of to be created ResultSet type
rsType
,
PyObject
the value of the to be created ResultSet concurrency
rsConcur
)

Prepares the statement and registers the OUT/INOUT parameters (if any).

protected void
registerOutParameters(CallableStatement
statement
statement
)

Registers the OUT/INOUT parameters of the statement.

public String

Returns:

String
toSql
()

Returns the call in the syntax:

{?
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COLUMN_TYPEback to summary
protected static final int COLUMN_TYPE

Field COLUMN_TYPE

columnsback to summary
protected PyObject columns

Field columns

cursorback to summary
protected PyCursor cursor

Field cursor

DATA_TYPEback to summary
protected static final int DATA_TYPE

Field DATA_TYPE

DATA_TYPE_NAMEback to summary
protected static final int DATA_TYPE_NAME

Field DATA_TYPE_NAME

inputSetback to summary
protected BitSet inputSet

Field inputSet

LENGTHback to summary
protected static final int LENGTH

Field LENGTH

NAMEback to summary
protected static final int NAME

Field NAME

NULLABLEback to summary
protected static final int NULLABLE

Field NULLABLE

PRECISIONback to summary
protected static final int PRECISION

Field PRECISION

procedureCatalogback to summary
protected PyObject procedureCatalog

Field procedureCatalog

procedureNameback to summary
protected PyObject procedureName

Field procedureName

procedureSchemaback to summary
protected PyObject procedureSchema

Field procedureSchema

SCALEback to summary
protected static final int SCALE

Field SCALE

Constructor Detail

Procedureback to summary
public Procedure(PyCursor cursor, PyObject name) throws SQLException

Constructor Procedure

Parameters
cursor:PyCursor

cursor an open cursor

name:PyObject

name a string or tuple representing the name

Method Detail

fetchColumnsback to summary
protected void fetchColumns() throws SQLException

Get the columns for the stored procedure.

getDefaultback to summary
protected PyObject getDefault()

The value for a missing schema or catalog. This value is used to find the column names for the procedure. Not all DBMS use the same default value; for instance Oracle uses an empty string and SQLServer a null. This implementation returns the empty string.

Returns:PyObject

the default value (the empty string)

See Also
java.sql.DatabaseMetaData#getProcedureColumns

getProcedureNameback to summary
protected String getProcedureName()

Construct a procedure name for the relevant schema and catalog information.

isInputback to summary
public boolean isInput(int index) throws SQLException

This method determines whether the param at the specified index is an IN or INOUT param for a stored procedure. This is only configured properly AFTER a call to normalizeInput().

Parameters
index:int

JDBC indexed column index (1, 2, ...)

Returns:boolean

true if the column is an input, false otherwise

normalizeInputback to summary
public void normalizeInput(PyObject params, PyObject bindings) throws SQLException

Prepare the binding dictionary with the correct datatypes.

Parameters
params:PyObject

a non-None list of params

bindings:PyObject

a dictionary of bindings

prepareCallback to summary
public CallableStatement prepareCall() throws SQLException

Prepares the statement and registers the OUT/INOUT parameters (if any).

Returns:CallableStatement

CallableStatement

prepareCallback to summary
public CallableStatement prepareCall(PyObject rsType, PyObject rsConcur) throws SQLException

Prepares the statement and registers the OUT/INOUT parameters (if any).

Parameters
rsType:PyObject

the value of to be created ResultSet type

rsConcur:PyObject

the value of the to be created ResultSet concurrency

Returns:CallableStatement

CallableStatement

registerOutParametersback to summary
protected void registerOutParameters(CallableStatement statement) throws SQLException

Registers the OUT/INOUT parameters of the statement.

Parameters
statement:CallableStatement

statement

toSqlback to summary
public String toSql() throws SQLException

Returns the call in the syntax:

{? = call <procedure-name>(?, ?, ...)}
{call <procedure-name>(?, ?, ...)}
As of now, all parameters variables are created and no support for named variable calling is supported.
Returns:String

String