Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 14th, 2005, 10:45 AM
stuyg stuyg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 9 stuyg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 44 sec
Reputation Power: 0
Unhappy Helllp - Functions

Need Help, the following procedure/function is supposed to execute a query and return a resultset object to the calling application, however, when i try to create it in oracle i get the errors shown below!


CREATE OR REPLACE FUNCTION fu_checkAlert
(
PID_in IN INTEGER
)
RETURN "rs" AS LANGUAGE JAVA NAME 'ResultSet';
BEGIN
SELECT * FROM Alert WHERE PID = PID_in ORDER BY alertdate;
END;
/
show err;


Warning: Function created with compilation errors.

Errors for FUNCTION FU_CHECKALERT:

LINE/COL ERROR
-------- -----------------------------------------------------------------
6/1 PLS-00103: Encountered the symbol "SELECT"





PLEASE HELLLP ME!!!!

Reply With Quote
  #2  
Old February 14th, 2005, 10:51 AM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,308 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 2 m 57 sec
Reputation Power: 48
I know nothing about java interfaces but the comma after resultset is wrong

Code:
CREATE OR REPLACE FUNCTION fu_checkAlert
(
PID_in IN INTEGER
)
RETURN "rs" AS LANGUAGE JAVA NAME 'ResultSet'
IS
  
BEGIN
SELECT * FROM Alert WHERE PID = PID_in ORDER BY alertdate; 
return rs;
END;
/


rs should be created in the function. Don't you have another function similar this to copy? One that returns a java result set?

Reply With Quote
  #3  
Old February 14th, 2005, 02:30 PM
stuyg stuyg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 9 stuyg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 44 sec
Reputation Power: 0
Quote:
Originally Posted by jim mcnamara
rs should be created in the function. Don't you have another function similar this to copy? One that returns a java result set?


Unfortunately i dont have any other functions to copy, i'm a complete newbie to oracle and i'm having difficulty getting to grips with it!
I can execute the query directly from my java code and get the resultset that way but it's not how i want to do it, because i have 2 or 3 apps calling it, was trying to do a stored proc too, but that wouldn't work either!

Reply With Quote
  #4  
Old February 20th, 2005, 10:59 PM
wubandit99 wubandit99 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 30 wubandit99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 4
It looks like you are trying to mix 2 different things... Calling PL/SQL stored procedures from Java, and calling Java from Oracle. I believe you want the first... In that case, your procedure would just be...


Code:
CREATE OR REPLACE FUNCTION fu_checkAlert
(
PID_in IN INTEGER
)
RETURN sys_refcursor
IS

  v_rs sys_refcursor;
  
BEGIN

  open v_rs for '
    SELECT * FROM Alert WHERE PID = '||PID_in||' ORDER BY alertdate'; 

  return v_rs;

END;



The "as Language Java Name '......'" syntax is for creating procedures/functions that allow you to call Java methods that have been loaded into Oracle.

Hope this helps.

-wb-

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Helllp - Functions


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway