You can use a prepared statement in place of #sql{addStatement}.
INSERT INTO tableName (column_1, column_2... column_n) VALUES (?, ?, ?)
The value of tableName is the value of the Table annotation that is set on the entity type. If that annotation is missing from the type definition, the value of tableName is the type name.
The order of the column fields in the statement reflects the order of the fields in the type definition. Each question mark in the VALUES clause is replaced with the corresponding value in the entity.
A column entry such as column_1 is a name; specifically, the value of the Column annotation for a field in the type definition. If that annotation is missing from the field in the type definition, the name in the statement is the name of the field in the type definition.
If you are adding simple values instead of an entity, you must specify an SQL INSERT statement. The statement format is as shown for entity.
If you issue a prepared statement, the variable is optional and is ignored if present.
// you can use an entity such as record named myPayment add myPayment to ds; // alternatively, you can use a set of simple values // and specify the SQL INSERT statement. add 6, "Services", 12.00, myPayment.due_date to ds with #sql{ insert into Payment (category, description, amount, due_date) values (?, ? , ?, ?) };
Target | Issue |
---|---|
Java | No issues |
JavaScript | Database access is not supported in JavaScript. |