Re: Nesting Level - What should I expect when executing after prep
- From: Kimberly Blum <KimberlyBlum@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Jan 2007 10:44:01 -0800
WE don't write the JDBC code (some of our clients use it); I just want to
know how to identify procedures that are called by one of the sp_*
procedures, or alternatively, be able to identify connections that use the
sp_* procedures to execute other procedures.
"Joe Weinstein" wrote:
.
joeNOSPAM@xxxxxxx wrote:
Hi. I am saying you should assume that *any* JDBC code you write
that executes a PreparedStatement (which includes CallableStatements)
will be executed via a stored procedure. If your PreparedStatement
is being asked to execute one of your stored procedures, that stored
procedure will always see the nesting level as > 1.
Your other alternative is to call your procedures with a plain
statement. You would have to send the procedure name and all
it's arguments as a single SQL string.
Joe Weinstein at BEA Systems
eg:
Statement s = c.createStatement();
boolean getResultSetNow = s.execute("EXEC my_procedure " + myFirstArg + ", " + mySecondArg);
int updateCount = -1;
while (true) { // handle all in-line results from any procedure
if (getResultSetNow) {
ResultSet r = s.getResultSet();
while (r.next()) {
// fully process result set before calling getMoreResults() again!
}
r.close();
} else {
updateCount = s.getUpdateCount();
if (updateCount != -1) { // it's a valid update count
if (you want) System.out.println("Processing an update count of " + updateCount);
}
}
if ((!getResultSetNow) && (updateCount == -1)) break; // done with loop
getResultSetNow = s.getMoreResults();
}
If any of your stored procedures return output parameters though,
then you are going to have to use a CallableStatement, and expect
that the procedure you call will find the nesting level to be higher
than if you called if from a command-runner.
Joe Weinstein at BEA Systems
- Follow-Ups:
- Re: Nesting Level - What should I expect when executing after prep
- From: Joe Weinstein
- Re: Nesting Level - What should I expect when executing after prep
- References:
- Re: Nesting Level - What should I expect when executing after prepareC
- From: Joe Weinstein
- Re: Nesting Level - What should I expect when executing after prep
- From: Kimberly Blum
- Re: Nesting Level - What should I expect when executing after prep
- From: joeNOSPAM@xxxxxxx
- Re: Nesting Level - What should I expect when executing after prep
- From: Joe Weinstein
- Re: Nesting Level - What should I expect when executing after prepareC
- Prev by Date: Re: Nesting Level - What should I expect when executing after prep
- Next by Date: Re: Nesting Level - What should I expect when executing after prep
- Previous by thread: Re: Nesting Level - What should I expect when executing after prep
- Next by thread: Re: Nesting Level - What should I expect when executing after prep
- Index(es):
Relevant Pages
|
Loading