Is it possible to send the box DEFAULTexplicitly through JDBC , as in INSERT INTO sometables VALUES (blah, DEFAULT)? (I'm pretty sure the answer is no, but I'm looking for confirmation from a JDBC expert).
Let's say you had PreparedStatementlike:
INSERT INTO mytable(a, b) VALUES (?, ?)
for table:
CREATE TABLE mytable (
a integer,
b integer default some_function()
);
and you wanted to use the database set DEFAULTfor mytable.bsome executions in the package, but not others.
In regular SQL, you should write:
INSERT INTO mytable(a, b) VALUES (1, 42)
INSERT INTO mytable(a, b) VALUES (2, DEFAULT);
...
or of course:
INSERT INTO mytable(a, b) VALUES (1, 42)
INSERT INTO mytable(a) VALUES (2);
... but you cannot do it through JDBC. setString("DEFAULT")of course will not send the keyword DEFAULT, just a literal string 'DEFAULT'.
Is there a way to set the -placeholder parameter, which means DEFAULTin any commonly used drivers?
I see no way to do this with the standard API and spec.
I present something like:
pstmt.setObject(2, Postgresql.DEFAULT, Types.OTHER);
Postgresql.DEFAULT - , setDefault() PreparedStatement.
- ?