This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Urgent

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Using callable statement, can i call a function inside package[In Oracle]? If so, how can i call? FYI, the function has select statement inside it and it returns all records in a table.
Thanks,
Sankar
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
find following dummy code snippet if useful to u..
String strFunName = {?=call(?....?)}
where first ? is for return value and
second ? is for parameter u passed it can be any no.
now call the prepareCall method of con like in following steps
1) CallableStatement cStmt = con.prepareCall(strFunName );
2) cStmt.setXXX(parameterValue);
3) cStmt.registerOutParameter(1, Types.NUMERIC)
4) cStmt.executeUpdate();
5) if the return type is int..
int value = cStmt.getInt(1);
thats it
 
Shiv Sidhaarth
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for ur reply. I tried it. But, it seems i cant call a function using callable statement. Bcos, it gave the error as
********************************************************
java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00221: 'MYRECRTN' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
*********************************************************
I have declared and defined MYRECRTN as function inside mypackage. I prepared the callable statement using "{call mypackage.myrecrtn()}".
Is there any other way to call a function from java???
Thanks in advance,
Sankar

Originally posted by Himanshu Khanna:
find following dummy code snippet if useful to u..
String strFunName = {?=call(?....?)}
where first ? is for return value and
second ? is for parameter u passed it can be any no.
now call the prepareCall method of con like in following steps
1) CallableStatement cStmt = con.prepareCall(strFunName );
2) cStmt.setXXX(parameterValue);
3) cStmt.registerOutParameter(1, Types.NUMERIC)
4) cStmt.executeUpdate();
5) if the return type is int..
int value = cStmt.getInt(1);
thats it


 
Himanshu Khanna
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey , it may be a case of Lower case / Upper case .Please check the names of the package & the function have the same case in Oracle as well as Ur java code
 
Shiv Sidhaarth
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Case is not a problem. I checked it.
 
I can't renounce my name. It's on all my stationery! And hinted in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic