|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.microdeveloper.data.OracleStoredProcedure
public class OracleStoredProcedure
A generic stored procedure execution class which encapsulates the procedure with the connection, variables, and results.
Variables are loaded to an argument stack then read like a resultSet. This is very similar to the JDBC call and only differs in the encapsulation.
In SQL*Plus this could be executed like this:
VARIABLE c VARCHAR2(255);
EXEC addtxt('Smith','Scott',:c);
PRINT c
To do the same with this class the actions would be:
// assign the arguments
addArg(1,Types.VARCHAR,IN,"Smith");
addArg(2,Types.VARCHAR,IN,"Scott");
addArg(3,Types.VARCHAR,OUT,null);
// execute the procedure
boolean result = doProcedure(Connection, 'addtxt');
//read the results
System.out.println((String) getArg(3));
Stored Functions
Assume you want to execute a stored function that adds two varchar2 variables together like this:
addtxt(a IN VARCHAR2, b IN VARCHAR2) RETURN VARCHAR2
In SQL*Plus this could be executed like this:
VARIABLE c VARCHAR2(255);
EXEC c:= addtxt('Smith','Scott');
PRINT c
To do the same with this class the actions would be:
// assign the arguments
addArg(1,Types.VARCHAR,IN,"Smith");
addArg(2,Types.VARCHAR,IN,"Scott");
// execute the function
object result = doFunction(Connection, 'addtxt');
// read the results
System.out.println((String) result);
Field Summary | |
---|---|
static int |
DIR
Internal DIR value |
static int |
FUNCTION
Function index value |
static int |
IN
IN argument type |
static int |
INOUT
INOUT argument type |
static int |
OUT
OUT argument type |
static int |
POS
Internal POS value |
static int |
PROCEDURE
Procedure index value |
static int |
TYPE
Internal TYPE value |
static int |
VAL
Internal VAL value |
Constructor Summary | |
---|---|
OracleStoredProcedure()
Create a new OracleStoredProcedure object |
Method Summary | |
---|---|
boolean |
addArg(int pos,
int type,
int dir,
Object val)
Add an argument to the this object. |
String |
argsToString(int callType)
Convert the arguments to a String. |
boolean |
clearArg(int pos)
Remove a single argument from the this object. |
boolean |
clearArgs()
Remove all arguments from the this object. |
Object |
doFunction(Connection conn,
String procedure)
Execute the given function. |
boolean |
doProcedure(Connection conn,
String procedure)
Executes the given stored procedure. |
List |
getArg(int pos)
Get a single argument from this object. |
Object |
getArgVal(int pos)
Get a single arguments value. |
OracleStoredProcedureInterface |
getOracleStoredProcedureInterface()
Obtain a new OracleStoredProcedure interface |
boolean |
setArgVal(int pos,
Object val)
Set an arguments value |
boolean |
setOutValues(CallableStatement s)
Establish the outbound parameters |
boolean |
setParameter(CallableStatement s,
int pos)
Establish the argument as a parameter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int IN
public static final int OUT
public static final int INOUT
public static final int POS
public static final int TYPE
public static final int DIR
public static final int VAL
public static final int FUNCTION
public static final int PROCEDURE
Constructor Detail |
---|
public OracleStoredProcedure()
Method Detail |
---|
public OracleStoredProcedureInterface getOracleStoredProcedureInterface()
public Object doFunction(Connection conn, String procedure) throws SQLException
conn
- established connection object from a JDBC connectionprocedure
- name of the function to execute
SQLException
- thrown if the function cannot be executeddoProcedure(Connection,String)
,
Connector
,
ConnectionPool
public boolean doProcedure(Connection conn, String procedure) throws SQLException
conn
- established connection object from a JDBC connectionprocedure
- name of the procedure to execute
SQLException
- thrown if the procedure cannot be executeddoFunction(Connection,String)
,
Connector
,
ConnectionPool
public boolean addArg(int pos, int type, int dir, Object val)
pos
- position in the procedures argument listdir
- argument direction in IN, OUT, or INOUTval
- the value of an IN or INOUT parameterpublic boolean clearArgs()
public boolean clearArg(int pos)
pos
- index of the element to remove
public List getArg(int pos)
pos
- the index of the argument to return
public Object getArgVal(int pos)
pos
- the index of the argument to return
public boolean setParameter(CallableStatement s, int pos)
s
- CallableStatement to setpos
- argument index to set
public String argsToString(int callType)
callType
- a constant call type
public boolean setOutValues(CallableStatement s)
s
- CallableStatement to set
public boolean setArgVal(int pos, Object val)
pos
- index of the argument to setval
- value of the argument
|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |