Home » SQL & PL/SQL » SQL & PL/SQL » pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced
pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618281] Thu, 10 July 2014 05:26 Go to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi all,

create or replace pkg
as
Procedure1
is
cursor v_cur(v_num)
is
select coulmn1
from tab
where number=v_num;

for c_rec in v_cur(v_num) loop
.......
........
end loop;

end procedure1;

procedure x_name(v_num in number)
is

end procedure x_name;


I need to pass v_num as IN parameter in the x_name Procedure , which are already passing in the Cursor For loop, is this possible?

Thanks
Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618283 is a reply to message #618281] Thu, 10 July 2014 05:29 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
mist598 wrote on Thu, 10 July 2014 15:56
is this possible?


Did you try? If I or someone says NO you can't then won't you try?

And after 800+ posts, once again have a look at code tags and Test case

Edit : Link to code tags and test case wiki

[Updated on: Thu, 10 July 2014 06:22]

Report message to a moderator

Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618294 is a reply to message #618283] Thu, 10 July 2014 07:03 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
As usual your problem description is lacking in detail.
Variables can always be passed as parameters to procedures as long as they are in scope.
It is not at all clear from what you posted what v_num is, where it's declared, or whether it's in scope at the point you need it.
Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618295 is a reply to message #618294] Thu, 10 July 2014 07:14 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
create or replace pkg
as
Procedure1(p_cust_id in varchar2)
is
cursor v_cur(v_num)
is
select coulmn1
from tab
where number=v_num;
  Begin
       BEGIN
          SELECT SUBSTR(customer_number,1,3),customer_name
            INTO v_cust_num,v_cust_name
            FROM ar_customers
           WHERE customer_id=p_cust_id;
      END;
    for c_rec in v_cur(v_num) loop
     .......
     ........
    end loop;

end procedure1;

procedure x_name(v_num in number)
is
select col1,col2
end procedure x_name;

[Updated on: Thu, 10 July 2014 07:15]

Report message to a moderator

Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618296 is a reply to message #618295] Thu, 10 July 2014 07:21 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
procedure x_name(v_num in number)
is
select col1,col2
end procedure x_name;


Do you think this is a valid code in any way?

Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618297 is a reply to message #618296] Thu, 10 July 2014 07:28 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:

Do you think this is a valid code in any way?


No , not correct but i have given sample query. If i did any wrong sorry for that
Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618300 is a reply to message #618297] Thu, 10 July 2014 07:43 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
mist598 wrote on Thu, 10 July 2014 17:58
No , not correct but i have given sample query. If i did any wrong sorry for that


cookiemonster wrote on Thu, 10 July 2014 17:33
It is not at all clear from what you posted what v_num is, where it's declared, or whether it's in scope at the point you need it.

Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618301 is a reply to message #618297] Thu, 10 July 2014 07:43 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
A sample that doesn't help us to understand what your problem is.
A more completely sample may allow us to see where you are going wrong, but the above tells us nothing about what v_num is.
Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618302 is a reply to message #618301] Thu, 10 July 2014 07:51 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
v_num is declared in the Procedure1
Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618303 is a reply to message #618302] Thu, 10 July 2014 07:54 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
No. Where is it declared?
Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618304 is a reply to message #618303] Thu, 10 July 2014 07:57 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
It's declared anywhere in the example you posted.
But assuming it is declared in procedure1 - if x_name is called from procedure1 you can pass the v_num to it as a parameter.
So what problem are you having trying to do that?
Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618305 is a reply to message #618303] Thu, 10 July 2014 07:57 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
create or replace pkg xxc
as
Procedure1(p_cust_id in varchar2)
is
v_cust_num number;-->Here!
cursor v_cur(v_cust_num)
is
select coulmn1
from tab
where number=v_cust_num;
  Begin
       BEGIN
          SELECT SUBSTR(customer_number,1,3),customer_name
            INTO v_cust_num,v_cust_name
            FROM ar_customers
           WHERE customer_id=p_cust_id;
      END;
    for c_rec in v_cur(v_cust_num) loop
     .......
     ........
    end loop;

end procedure1;

procedure x_name(v_cust_num in number)
is
select col1,col2
end procedure x_name;
end xxc;
Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618306 is a reply to message #618304] Thu, 10 July 2014 08:00 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:

It's declared anywhere in the example you posted.
But assuming it is declared in procedure1 - if x_name is called from procedure1 you can pass the v_num to it as a parameter.
So what problem are you having trying to do that?


Yes, i need this one , i am just asking is this possible or not?

Thanks cookiemonster.. Smile
Re: pass parameter into the Procedure , which are passing into the Cursor for loop in the Another Proced [message #618307 is a reply to message #618306] Thu, 10 July 2014 08:04 Go to previous message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Once again, I advise you to read:
PL/SQL User's Guide and Reference
Application Developer's Guide - Fundamentals

Trying to code without knowing the basics is just a waste of time, yours and, more important as it is shared among people that really needs help, ours.

Previous Topic: pls help in query
Next Topic: SQL
Goto Forum:
  


Current Time: Fri Apr 19 15:18:55 CDT 2024