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 October 7th, 2004, 09:03 AM
fkoskotas fkoskotas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 56 fkoskotas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 16 sec
Reputation Power: 4
exec an oracle stored procedure with output param

I'm trying to run the following procedure and get the error and the bottom, why? the parameter is an output parameter what is it exepecting to be passed to it?

1 create or replace procedure GetStnGroups (groupoutout out varchar2) is
2 groupout varchar2(8);
3 --as
4 cursor stngroupout is
5 select distinct stn_group
6 from test_header
7 where test_datetime > sysdate -365;
8 begin
9 for my_cursor in stngroupout loop
10 begin
11 --for i in 1..my_cursor.stn_group loop
12 dbms_output.put_line('stn group without package : ' || my_cursor.stn_group);
13 groupout := my_cursor.stn_group;
14 dbms_output.put_line('stn group two : ' || groupout);
15 --end loop;
16 end;
17 end loop;
18* end GetStnGroups;
l06db > /

Procedure created.

l06db > exec GetStnGroups
begin GetStnGroups; end;

*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'GETSTNGROUPS'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

Reply With Quote
  #2  
Old October 7th, 2004, 09:55 AM
utecistu utecistu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 16 utecistu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
doesn't matter if is out, u still have 2 pass the parameter. for ex:

declare
c varchar2(100);
begin
GetStnGroups(c);
end;

Reply With Quote
  #3  
Old October 7th, 2004, 10:04 AM
fkoskotas fkoskotas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 56 fkoskotas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 16 sec
Reputation Power: 4
Quote:
Originally Posted by utecistu
doesn't matter if is out, u still have 2 pass the parameter. for ex:

declare
c varchar2(100);
begin
GetStnGroups(c);
end;


where do i declare it? so what am i suppose to pass it, a pseudo value?

Reply With Quote
  #4  
Old October 7th, 2004, 10:21 AM
utecistu utecistu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 16 utecistu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
run what i wrote.
not a value, but a variable of the same type as the parameter (as i did with "c" variable).

Reply With Quote
  #5  
Old October 7th, 2004, 10:31 AM
fkoskotas fkoskotas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 56 fkoskotas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 16 sec
Reputation Power: 4
Quote:
Originally Posted by utecistu
run what i wrote.
not a value, but a variable of the same type as the parameter (as i did with "c" variable).



ok, so that works. but how do i get it to work so when i do exec GetStnGroups(c) , i get the same results?

Reply With Quote
  #6  
Old October 8th, 2004, 03:00 AM
utecistu utecistu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 16 utecistu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
what is "c"? ... exactly, "c" needs 2 be declared. so, if u prefer 2 write a single line then just write it so.

SQL>declare c varchar2(100); begin GetStnGroups(c); end;
2 /

Reply With Quote
  #7  
Old October 8th, 2004, 08:22 AM
fkoskotas fkoskotas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 56 fkoskotas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 16 sec
Reputation Power: 4
Quote:
Originally Posted by utecistu
what is "c"? ... exactly, "c" needs 2 be declared. so, if u prefer 2 write a single line then just write it so.

SQL>declare c varchar2(100); begin GetStnGroups(c); end;
2 /


I need to be able to call the procedure from another app, so i need to be able to run it from sql*plus as
exec GetStnGroups(c)

Reply With Quote
  #8  
Old October 8th, 2004, 08:55 AM
utecistu utecistu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 16 utecistu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
well, if u need 2 call the procedure from another app, then delcare in that app the "c" variable the call GetStnGroups(c). the point is if u wanna call the proc u need 2 pass that parameter and 4 that u need 2 declare it somewhere, so do it in yr app.

Reply With Quote
  #9  
Old October 8th, 2004, 08:58 AM
fkoskotas fkoskotas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 56 fkoskotas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 16 sec
Reputation Power: 4
Quote:
Originally Posted by utecistu
well, if u need 2 call the procedure from another app, then delcare in that app the "c" variable the call GetStnGroups(c). the point is if u wanna call the proc u need 2 pass that parameter and 4 that u need 2 declare it somewhere, so do it in yr app.


do you have any experience with asp.net?

Reply With Quote
  #10  
Old October 8th, 2004, 10:58 AM
utecistu utecistu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 16 utecistu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
this.oracleConnection1.Open();
OracleCommand oracleCmd = new OracleCommand();
oracleCmd.Connection = this.oracleConnection1;
oracleCmd.CommandText = "GetStnGroups";
oracleCmd.CommandType = CommandType.StoredProcedure;
oracleCmd.Parameters.Add(new OracleParameter("c", OracleType.VarChar)).Direction = ParameterDirection.Output;
OracleDataAdapter oracleDA = new OracleDataAdapter( oracleCmd );
DataSet ds = new DataSet();
oracleDA.Fill(ds);

etc etc, i guess i wrote more then needed, the only part interesting is the one with passing that out parameter.
happier now?

Reply With Quote
  #11  
Old October 8th, 2004, 12:10 PM
fkoskotas fkoskotas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 56 fkoskotas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 16 sec
Reputation Power: 4
Quote:
Originally Posted by utecistu
this.oracleConnection1.Open();
OracleCommand oracleCmd = new OracleCommand();
oracleCmd.Connection = this.oracleConnection1;
oracleCmd.CommandText = "GetStnGroups";
oracleCmd.CommandType = CommandType.StoredProcedure;
oracleCmd.Parameters.Add(new OracleParameter("c", OracleType.VarChar)).Direction = ParameterDirection.Output;
OracleDataAdapter oracleDA = new OracleDataAdapter( oracleCmd );
DataSet ds = new DataSet();
oracleDA.Fill(ds);

etc etc, i guess i wrote more then needed, the only part interesting is the one with passing that out parameter.
happier now?



Hm, still not working. here is my asp.net code:
Function GetStationGroup()
'Dim querystring As String
'querystring = "select distinct stn_group from test_header where test_datetime > sysdate -365 "

Dim stngroup As String
stngroup = "cin"

OracleCommand1.CommandText = "StnGroupPkg.GetStnGroups"
OracleCommand1.CommandType = CommandType.StoredProcedure

'OracleCommand1.Parameters.Add("groupout", OracleClient.OracleType.VarChar, 8)

OracleCommand1.Parameters.Add("groupoutout", OracleClient.OracleType.VarChar, 8)

'OracleCommand1.Parameters("groupoutout").Direction = ParameterDirection.Input

'OracleCommand1.Parameters("groupoutout").Value = stngroup

OracleCommand1.Parameters("groupoutout").Direction = ParameterDirection.Output

Dim datareader As OracleClient.OracleDataReader
OracleConnection1.Open()

datareader = OracleCommand1.ExecuteReader
drpStnGroup.Items.Add("")
Do While datareader.Read
drpStnGroup.Items.Add(datareader(0).ToString())
Loop

Return datareader
OracleConnection1.Close()

End Function


here is the stored procedure:

create or replace procedure GetStnGroups (groupoutout out varchar2) is
cursor stngroupout is
select distinct stn_group
from test_header
where test_datetime > sysdate -365;
begin
for my_cursor in stngroupout loop
begin
dbms_output.put_line('stn group without package : ' || my_cursor.stn_group);
groupoutout := my_cursor.stn_group;
dbms_output.put_line('stn group two : ' || groupoutout);
end;
end loop;
end GetStnGroups;

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > exec an oracle stored procedure with output param


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 1 hosted by Hostway