    All Packages    This Package  Previous  Next

# Class sqlj.runtime.profile.ref.PositionedProfile

    java.lang.Object
       |
       +----sqlj.runtime.profile.ref.ProfileWrapper
               |
               +----sqlj.runtime.profile.ref.PositionedProfile

public class PositionedProfile
extends ProfileWrapper

A positioned profile is a connected profile wrapper which augments the functionality of the statement creation methods by intercepting any entries with role of POSITIONED, and handling execute of such an entry by creating a new sql operation dynamically with the runtime name of the cursor replacing the ? in the original CURRENT OF ? expression.

Entries with role of POSITIONED have a sql operation that includes the text WHERE CURRENT OF ?. For example, UPDATE TAB SET COL1=? WHERE CURRENT OF ?. The JDBC specification indicates that portable handling of CURRENT OF statements involves passing the name of the current-of-cursor as part of the sql operation rather than as a bind variable. Thus, in the above case, if the cursor name were "CURS", then the text of the new operation created at runtime would be UPDATE TAB SET COL1=? WHERE CURRENT OF CURS. To facilitate construction of the proper sql operation, the entry descriptor for POSITIONED entries is an Integer that describes which passed parameter represents the cursor.

If the operation also includes bind variables, these are stored in an internal cache until the new statement is created, and are then bound to the statement once it has been prepared. We assume that POSITIONED entries only occur with an executeType of EXECUTE_UPDATE and statementType of PREPARED_STATEMENT.

See Also:
  POSITIONED

##

PositionedProfile(DynamicProfile)
  Creates a new positioned profile that augments the functionality of the passed connected profile.

##

getStatement(int)
  Returns an executable statement object representing the statement at index "ndx" in the profile, where "ndx" is 0 based.
setWrappedProfile(ConnectedProfile)
  The underlying profile for a positioned profile can only be reset if the new profile is a dynamic profile.

##

PositionedProfile

     public PositionedProfile(DynamicProfile profile)

  Creates a new positioned profile that augments the functionality of the passed connected profile. Note that since the sql operation will be created at runtime, the passed profile must support dynamic operations.

  Parameters:
    profile - the dynamic connected profile to wrap

##

setWrappedProfile

     public boolean setWrappedProfile(ConnectedProfile newProfile)

  The underlying profile for a positioned profile can only be reset if the new profile is a dynamic profile.

  Overrides:
    setWrappedProfile in class ProfileWrapper

getStatement

     public RTStatement getStatement(int ndx) throws SQLException

  Returns an executable statement object representing the statement at index "ndx" in the profile, where "ndx" is 0 based. If the role of the entry at the given index is not POSITIONED, the statement is created using the `prepareStatement` method of the underlying dynamic profile. If the role is POSITIONED, the object returned is a statement that, when executed, dynamically prepares and executes a new statement with the text of the original statement, but the dynamic name of the cursor substituted in place of the '?'. All bound inputs are cached and transferred to the newly created statement before execution.

  It is assumed that POSITIONED statements are always handled with PREPARED statements via the executeUpdate method. If the entry info describes otherwise, this method will raise an exception.

  Parameters:
    the - index of the statement to return, 0 based.
  Throws: SQLException
    if an error occurs preparing the statement.
  Overrides:
    getStatement in class ProfileWrapper
  See Also:
    getRole, POSITIONED, getStatementType, getExecuteType

    All Packages    This Package  Previous  Next