|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
doesn't matter if is out, u still have 2 pass the parameter. for ex:
declare c varchar2(100); begin GetStnGroups(c); end; |
|
#3
|
|||
|
|||
|
Quote:
where do i declare it? so what am i suppose to pass it, a pseudo value? |
|
#4
|
|||
|
|||
|
run what i wrote.
not a value, but a variable of the same type as the parameter (as i did with "c" variable). |
|
#5
|
|||
|
|||
|
Quote:
ok, so that works. but how do i get it to work so when i do exec GetStnGroups(c) , i get the same results? ![]() |
|
#6
|
|||
|
|||
|
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 / |
|
#7
|
|||
|
|||
|
Quote:
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) |
|
#8
|
|||
|
|||
|
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.
|
|
#9
|
|||
|
|||
|
Quote:
do you have any experience with asp.net? |
|
#10
|
|||
|
|||
|
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? ![]() |
|
#11
|
|||
|
|||
|
Quote:
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; |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > exec an oracle stored procedure with output param |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|