Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling SQL stored procedure from statment?

 
Richard Vagner
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone showed me that you can callable statement like this to the procedure:

stmt = con.createStatement();
rs = stmt.executeQuery("my_storedprocudure '1','newyork',25,'US'")


It actually works! I thought stored procedure only works with something like con.prepareCall("{call my_sp(?,?,?,?,?)}" then pass in the parameters. Will that achieve the same result?

[ May 05, 2005: Message edited by: Richard Vagner ]
[ May 05, 2005: Message edited by: Richard Vagner ]
 
Annie Smith
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try this:


I guess something like this should work too.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard,
Thanks, that's nice to know. Now if only you'd mention what database and JDBC driver that works for, it may actually prove useful to someone -- because it definitely doesn't work with my Oracle 9i database and Oracle JDBC driver.

In any case, regardless of which (JDBC) interface you use, your database is going to receive text -- which it will try to parse as valid SQL. Remember, "CallableStatement" inherits from "Statement", so I guess it's logical that your system would work.

Good Luck,
Avi.
 
Richard Vagner
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, both of you, very much. The datbase is MS SQL server
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic