j-star
j-star

Reputation: 1

JDBC execute INSERT statement with a function

How to use JDBC to execute an INSERT statement which has a user defined PL/SQL function in VALUES clause?

INSERT INTO table_name VALUES (plsql_func_name('?'),?,?,?);

Should prepareStatement() or callablestatement() be used?

Upvotes: 0

Views: 612

Answers (1)

Lajos Arpad
Lajos Arpad

Reputation: 77063

The apostrophes around the parameter are your undoing. Try it this way:

INSERT INTO table_name VALUES (plsql_func_name(?),?,?,?);

Remember that the apostrophes are handled by the prepared statement, as this is one of its main jobs (as it has to prevent potential SQL-injections as well).

Upvotes: 1

Related Questions