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

How to fetch a row using a procedure through JDBC ?

 
gavin sharma
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am calling this below procedure through JDBC to display the row associated with a particular (empid) but the code doesnt fetch anything. please tell me what am i doing wrong ?


 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your procedure does not return anything (they are not intended to). You need to either use an Out parameter for the procedure or use a function instead.

Having said all that, given the simplicity of the procedure, is there any reason why you are using one? Why not just use plain old JDBC with a PreparedStatement?
 
gavin sharma
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
am nt using plain statement to prevent sql injection (as someone suggested) and I tried using OUT parameter, still it doesnt return anything. However, could you tell me whats wrong with the below function because it doesnt get executed:-

create or replace function getdetails (empid number)
return myadmin%ROWTYPE
as
my_rec myadmin%ROWTYPE;
begin
select *
INTO my_rec
from myadmin
where employe_id=empid;
return my_rec;
end;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic