By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,004 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,004 IT Pros & Developers. It's quick & easy.

How to bind parameter to a function in DB2 (JDBC)

P: 1
Folks !

How do you pass an argument to "date" or for that mater any function in JDBC for DB2 ?

I am migrating an application from Oracle to DB2 (type IV driver) and I can't seem to be able to call "date" function with an argument. In oracle I could use

"insert into mytable (as_of_date) values ( to_date(?, 'YYYY-MM-DD'))")
with pstmt.setString(1, "2000-1-1")

Equivalent code in DB2 is

"insert into mytable (as_of_date) values ( date(?))")

However execute fails with SQLCODE -418, SQLSTATE 42610 SQLERRMC: Null

Insert without parameterization works:
insert into mytable (as_of_date) values ( date('2000-1-1')) .

I need to pass an argument though.


Apr 3 '07 #1
Share this Question
Share on Google+
1 Reply

P: 20
"insert into mytable (as_of_date) values ( ?)")

use preparedstatment.setDate(a, b)
Apr 4 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.