Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java code inside sql functions?

 
rish obe
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am running a sql query which uses some sql functions like date_add() or max()

Query is something like : delete from <tablename> where date=date_add(<date>,interval <expression> unit)

I wish to write the above query in java code
The problem is i am not able to pass the parameters to the sql functions in java code.

"delete from student where date=date_add("+date_variable+","+parameter_@+")"

How can this be done.
Any inputs?

Many thanks!
 
Scott Selikoff
author
Bartender
Posts: 4033
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post your java code? It's hard to know what you're doing wrong without see the JDBC code.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rish,
The usual way to achieve your aim is to use a PreparedStatement.

Good Luck,
Avi.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!