CustomProcedure

The CustomProcedure interface defines a custom procedure. Any class implementing this interface should define an empty constructor so that the custom procedure can be properly instantiated.

public interface CustomProcedure

This interface extends ProcedureReference.

All methods in the CustomProcedure except for the constructor can throw a CustomProcedureException if they encounter an error condition. Any exception thrown from these methods (including runtime exceptions) causes an error on the current action to be passed up as a system error.

Method Summary

void

commit

String

getDescription

String

getName

void

initialize

void

rollback

Serialization

The custom procedure class can implement the java.lang.Serializable interface to carry the compensation state across a server restart. Variables that do not need to be restored after a restart should be marked as transient.

Life Cycle

The life cycle of a custom procedure object is defined as follows:

Introspection time—A constructor is used to make an object, introspection methods are used to read method signatures, and then the object is discarded.
Runtime setup—A constructor is used to make a new object and initialize is called.
Runtime execution—Call invoke first, then retrieve and read from output parameter values, and then retrieve output values. You can do setup and then not invoke at all.
Runtime closing—If the object was invoked, call the close method when the invoke is complete. Always call close before rollback or commit. Connections or resources that are open or in use, and are not needed for commit or rollback, should be cleaned up at this point. For example, if a query was performed on a connection but no updates were performed, close the query now.
Runtime commit or rollback—If the object was invoked, call close first, and later call either commit or rollback. Call commit to commit on any connections where updates occurred, or call rollback to roll back all changes; after that, close or clean up all remaining connections and resources.

Threading

The close method can be called concurrently with any other call such as invoke or getOutputValues. In such cases, any pending methods should immediately throw a CustomProcedureException.

Method Detail

commit

public void commit()

This method commits an open transaction.

Throws

This method throws a CustomProcedureException if invoked for the parent transaction. It throws a SQLException if an error occurs.

 

getDescription

public String getDescription()

This method is called during data source introspection, and gets the description of the procedure. This method should not return NULL.

Returns

This method returns a description of the procedure.

 

getName

public String getName()

This method gets the short name of the procedure. This method is called during data source introspection. The short name can be overridden during data source configuration.

This method should not return NULL.

Returns

This method returns the short name of the procedure.

 

initialize

public void initialize(ExecutionEnvironment qenv)

This method is called once immediately after constructing the class, and initializes the query execution environment (ExecutionEnvironment). The execution environment contains methods that are executed to interact with the server.

Parameter

qenv—Query execution environment.

rollback

public void rollback()

This method rolls back an open transaction.

Throws

This method throws CustomProcedureException, if invoked for the parent transaction. It throws SQLException if an error occurs.