Prepare Command

The prepare command creates a java.sql.PreparedStatement using the value of the specified SQL command String, and assigns an identifier to the prepared statement so that other splice> commands can use the statement.

If a prepared statement with the specified Identifier name already exists in the command interpreter, an error is returned, and the previous prepared statement is left unchanged. If there are any errors in preparing the statement, no prepared statement is created.

If the Identifier specifies a connection Name, the statement is prepared on the specified connection.


PREPARE Identifier AS String


The identifier to assign to the prepared statement.


The command string to prepare.


splice> prepare seeMenu as 'SELECT * FROM menu';
splice> execute seeMenu;
COURSE    |ITEM                |PRICE
entree    |lamb chop           |14
dessert   |creme brulee        |6

splice> prepare addYears as 'update children set age = age + ? where name = ?';
splice> execute addYears using 'values (10, ''Abigail'')';