Top Description Methods
org.apache.derby.iapi.sql.conn

public Interface StatementContext

extends Context
Known Direct Implementers
org.apache.derby.impl.sql.conn.GenericStatementContext
Imports
org.apache.derby.iapi.services.context.Context, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.sql.execute.NoPutResultSet, org.apache.derby.iapi.sql.Activation, .ResultSet, .ParameterValueSet, org.apache.derby.iapi.sql.depend.Dependency

StatementContext keeps the context for a statement.

Method Summary

Modifier and TypeMethod and Description
public void
addDependency(Dependency
The dependency to track.
dy
)

Track a Dependency within this StatementContext.

public void
cancel()

Indicate that the statement which has allocated this statement context should cancel its execution.

public void
clearInUse()

Mark this context as not in use.

public void
clearSavePoint()

Clear the save point for the current statement.

public Activation
getActivation()

Get activation associated with this statement context, if any.

public short
getSQLAllowed()

Get the setting of the SQL allowed state.

public SQLSessionContext

Returns:

the current SQL session context
getSQLSessionContext
()

Get the current SQL session context.

public String

Returns:

the statement text
getStatementText
()

Return the text of the current statement.

public boolean

Returns:

true if the statement was invalidated.
getStatementWasInvalidated
()

Tells if this statement has been invalidated.

public NoPutResultSet[]

Returns:

NoPutResultSet[] The (sparse) array of tops of subquery ResultSet trees
getSubqueryTrackingArray
()

Get the subquery tracking array for this query.

public boolean
getSystemCode()

Return true if this statement is system code.

public boolean

Returns:

true if we are in a trigger context
inTrigger
()

Returns whether we started from within the context of a trigger or not.

public boolean

Returns:

true if in use
inUse
()

Is this statement context in use or not.

public boolean

Returns:

true if needs to be atomic
isAtomic
()

Indicates whether the statement needs to be executed atomically or not, i.e., whether a commit/rollback is permitted by a connection nested in this statement.

public boolean

Returns:

true if the statement execution should be cancelled.
isCancelled
()

Checks if the statement which has allocated this statement context should cancel its execution.

public boolean

Returns:

true if the statement is for creating a read only, non-updatable ResultSet
isForReadOnly
()

Is this statement for a read only, non-updatable ResultSet

public boolean

Returns:

true if this StatementContext is on the context stack. false otherwise.
onStack
()

Reports whether this StatementContext is on the context stack.

public void
resetSavePoint()

If this statement context has a savepoint, then it is reset to the current point.

public void
setActivation(Activation
activation
a
)

Mark this statement context as associated with this activation.

public void
setInUse(boolean
true if the parent started in the context of a trigger
inTrigger
,
boolean
true if the statement must be executed atomically
isAtomic
,
boolean
true if the statement is for producing non-updatable resultset
isForReadOnly
,
String
the text of the statement. Needed for any language statement (currently, for any statement that can cause a trigger to fire). Please set this unless you are some funky jdbc setXXX method or something.
stmtText
,
ParameterValueSet
parameter value set, if it has one
pvs
,
long
timeout value for the statement, in milliseconds. Zero means no timeout.
timeoutMillis
)

Mark this context as being in use.

public void
setParentRollback()

Indicate that, in the event of a statement-level exception, this context is NOT the last one that needs to be rolled back--rather, it is nested within some other statement context, and that other context needs to be rolled back, too.

public void
setSavePoint()

Set a save point for the current statement.

public void
setSQLAllowed(short allow, boolean
set to true to override more restrictive setting. Used to reset the permissions after a function call.
force
)

Set the level of SQL allowed in this and subsequent nested statements due to a routine call.

public void
setSQLSessionContext(SQLSessionContext
the SQL session context
ctx
)

Set the current SQL session context

public void
setSubqueryResultSet(int
The subquery # for this subquery
subqueryNumber
,
NoPutResultSet
The NoPutResultSet at the top of the subquery
subqueryResultSet
,
int
The total # of subqueries in the entire query
numSubqueries
)

Set the appropriate entry in the subquery tracking array for the specified subquery.

public void
setSystemCode()

Set to indicate statement is system code.

public void
setTopResultSet(ResultSet
The top ResultSet in the ResultSet tree
topResultSet
,
NoPutResultSet[]
(Sparse) of tops of subquery ResultSet trees
subqueryTrackingArray
)

Set the top ResultSet in the ResultSet tree for close down on an error.

Inherited from org.apache.derby.iapi.services.context.Context:
cleanupOnErrorgetContextManagergetIdNameisLastHandlerpopMepushMe

Method Detail

addDependencyback to summary
public void addDependency(Dependency dy) throws StandardException

Track a Dependency within this StatementContext. (We need to clear any dependencies added within this context on an error.

Parameters
dy:Dependency

The dependency to track.

Exceptions
StandardException:
Thrown on error
cancelback to summary
public void cancel()

Indicate that the statement which has allocated this statement context should cancel its execution. Usually called as a consequence of Statement.cancel() or a query timeout set with Statement.setQueryTimeout().

clearInUseback to summary
public void clearInUse()

Mark this context as not in use. This is important because we always leave the top statement context on the stack, and we don't want to clean it up if a statement level exception happens while the context is not in use.

clearSavePointback to summary
public void clearSavePoint() throws StandardException

Clear the save point for the current statement.

Exceptions
StandardException:
Thrown on error
getActivationback to summary
public Activation getActivation()

Get activation associated with this statement context, if any. Used to link up stack of activations of calls in nested connections, see GenericPreparedStatement#getActivation.

getSQLAllowedback to summary
public short getSQLAllowed()

Get the setting of the SQL allowed state.

getSQLSessionContextback to summary
public SQLSessionContext getSQLSessionContext()

Get the current SQL session context.

Returns:SQLSessionContext

the current SQL session context

getStatementTextback to summary
public String getStatementText()

Return the text of the current statement. Note that this may be null. It is currently not set up correctly for ResultSets that aren't single row result sets (e.g SELECT) and setXXXX/getXXXX jdbc methods.

Returns:String

the statement text

getStatementWasInvalidatedback to summary
public boolean getStatementWasInvalidated()

Tells if this statement has been invalidated.

Returns:boolean

true if the statement was invalidated.

getSubqueryTrackingArrayback to summary
public NoPutResultSet[] getSubqueryTrackingArray() throws StandardException

Get the subquery tracking array for this query. (Useful for runtime statistics.)

Returns:NoPutResultSet[]

NoPutResultSet[] The (sparse) array of tops of subquery ResultSet trees

Exceptions
StandardException:
Thrown on error
getSystemCodeback to summary
public boolean getSystemCode()

Return true if this statement is system code.

inTriggerback to summary
public boolean inTrigger()

Returns whether we started from within the context of a trigger or not.

Returns:boolean

true if we are in a trigger context

inUseback to summary
public boolean inUse()

Is this statement context in use or not.

Returns:boolean

true if in use

isAtomicback to summary
public boolean isAtomic()

Indicates whether the statement needs to be executed atomically or not, i.e., whether a commit/rollback is permitted by a connection nested in this statement.

Returns:boolean

true if needs to be atomic

isCancelledback to summary
public boolean isCancelled()

Checks if the statement which has allocated this statement context should cancel its execution.

Returns:boolean

true if the statement execution should be cancelled.

isForReadOnlyback to summary
public boolean isForReadOnly()

Is this statement for a read only, non-updatable ResultSet

Returns:boolean

true if the statement is for creating a read only, non-updatable ResultSet

onStackback to summary
public boolean onStack()

Reports whether this StatementContext is on the context stack.

Returns:boolean

true if this StatementContext is on the context stack. false otherwise.

resetSavePointback to summary
public void resetSavePoint() throws StandardException

If this statement context has a savepoint, then it is reset to the current point. Otherwise, it is a noop.

Exceptions
StandardException:
Thrown on error
setActivationback to summary
public void setActivation(Activation a)

Mark this statement context as associated with this activation.

Parameters
a:Activation

activation

setInUseback to summary
public void setInUse(boolean inTrigger, boolean isAtomic, boolean isForReadOnly, String stmtText, ParameterValueSet pvs, long timeoutMillis)

Mark this context as being in use.

Parameters
inTrigger:boolean

true if the parent started in the context of a trigger

isAtomic:boolean

true if the statement must be executed atomically

isForReadOnly:boolean

true if the statement is for producing non-updatable resultset

stmtText:String

the text of the statement. Needed for any language statement (currently, for any statement that can cause a trigger to fire). Please set this unless you are some funky jdbc setXXX method or something.

pvs:ParameterValueSet

parameter value set, if it has one

timeoutMillis:long

timeout value for the statement, in milliseconds. Zero means no timeout.

setParentRollbackback to summary
public void setParentRollback()

Indicate that, in the event of a statement-level exception, this context is NOT the last one that needs to be rolled back--rather, it is nested within some other statement context, and that other context needs to be rolled back, too.

setSavePointback to summary
public void setSavePoint() throws StandardException

Set a save point for the current statement.

Note

This needs to be off of the StatementContext so that it gets cleared on a statement error.

Exceptions
StandardException:
Thrown on error
setSQLAllowedback to summary
public void setSQLAllowed(short allow, boolean force)

Set the level of SQL allowed in this and subsequent nested statements due to a routine call. Value must be one of RoutineAliasInfo.{MODIFIES_SQL_DATA, READS_SQL_DATA, CONTAINS_SQL, NO_SQL}

Parameters
force:boolean

set to true to override more restrictive setting. Used to reset the permissions after a function call.

setSQLSessionContextback to summary
public void setSQLSessionContext(SQLSessionContext ctx)

Set the current SQL session context

Parameters
ctx:SQLSessionContext

the SQL session context

setSubqueryResultSetback to summary
public void setSubqueryResultSet(int subqueryNumber, NoPutResultSet subqueryResultSet, int numSubqueries) throws StandardException

Set the appropriate entry in the subquery tracking array for the specified subquery. Useful for closing down open subqueries on an exception.

Parameters
subqueryNumber:int

The subquery # for this subquery

subqueryResultSet:NoPutResultSet

The NoPutResultSet at the top of the subquery

numSubqueries:int

The total # of subqueries in the entire query

Exceptions
StandardException:
Thrown on error
setSystemCodeback to summary
public void setSystemCode()

Set to indicate statement is system code. For example a system procedure, view, function etc.

setTopResultSetback to summary
public void setTopResultSet(ResultSet topResultSet, NoPutResultSet[] subqueryTrackingArray) throws StandardException

Set the top ResultSet in the ResultSet tree for close down on an error.

Parameters
topResultSet:ResultSet

The top ResultSet in the ResultSet tree

subqueryTrackingArray:NoPutResultSet[]

(Sparse) of tops of subquery ResultSet trees

Exceptions
StandardException:
Thrown on error