Portlet Factory, Version 6.1.2


 

About writing custom set methods for input parameters

If you specify a "Custom" JDBC type-cast for an input parameter of the SQL statement, then you will need to include in your model a method that will perform a type-cast and value definition of the parameter for the builder.

These custom methods must take the following parameters and return void:

BuilderName

This string parameter will contain the name of the SQL Statement builder that is calling the method to perform a custom type-cast and value definition. You can define one method for each custom type-cast you have defined or you can bundle all of your type-casts together and use this input to identify which specific type-cast to apply when called by the builder.

statement

This object parameter is the actual JDBC PreparedStatement or CallableStatement that was created by the builder and is being prepared for execution. The method is responsible for setting the input type of the positional parameter indicated by the position parameter. It is also responsible for defining the input value to be used by the statement when it s executed.

position

This integer parameter identifies the positional parameter in the SQL statement for which the type-cast is to be performed.

The following Java code sample is the body of a custom set method for an input parameter. In this example we do not need to differentiate between SQL Statement builders, so we ignore the BuilderName input. We cast the statement parameter into a JDBC PreparedStatement and then proceed to set the value and type of the statement s positional parameter denoted by the position parameter of the method.

try PreparedStatement ps = (PreparedStatement) statement; if( ps != null ) ps.setString( position, "SYS" ); catch( SQLException e ) e.printStackTrace();
}

Parent topic: SQL Statement builder


Library | Support |