Home » Other » Client Tools » i cudnt use bind variables in toad ..pls find me a solution for this. .
|
Re: i cudnt use bind variables in toad ..pls find me a solution for this. . [message #322772 is a reply to message #322764] |
Mon, 26 May 2008 03:44 |
pointers
Messages: 451 Registered: May 2008
|
Senior Member |
|
|
Hi sayed,
If i am correct, 'variable' is a sql * plus commnad and its not a plsql commnad. so you cant use it in a plsql block.
plsql uses bind variable concept automatically when you use variables.
But to use in 'execute immediate' we go for bind variables concept, as the value is passed during the run time.
try the below
create or replace procedure mine_1(a in number)
is
begin
execute immediate 'update mine_emp set sal=sal*2 where emp_id=:b' using a;
end;
Here 'b' is a bind variable and no need to define it.
Regards,
Pointers.
|
|
|
|
Re: i cudnt use bind variables in toad ..pls find me a solution for this. . [message #322778 is a reply to message #322764] |
Mon, 26 May 2008 03:54 |
|
thanks for your replies./ ...
CREATE OR REPLACE Procedure get_custid
(s_name IN varchar2,s_address IN varchar2,s_city IN varchar2,s_state IN varchar2,
s_phone IN varchar2,s_mobile IN number,s_email IN varchar2,s_custid OUT number,
r_name IN varchar2,r_address IN varchar2,r_city IN varchar2,r_state IN varchar2,
r_phone IN varchar2,r_mobile IN number,r_email IN varchar2,r_custid OUT number)
IS
v_s_cityid number;
v_r_cityid number;
cursor GET_S_CITYID is
select CITY_ID
from L_CITY
where CITY_NAME=s_city ;
cursor GET_R_CITYID is
select CITY_ID
from L_CITY
where CITY_NAME=r_city;
begin
open GET_S_CITYID;
fetch GET_S_CITYID into v_s_cityid;
if GET_S_CITYID%notfound then
insert into L_CITY(CITY_ID,CITY_NAME)
values (l_city_id.nextval,s_city);
end if;
insert into L_CUSTOMER( CUST_ID,CUST_NAME,ADDRESS,PHONE_NUMBER,MOBILE_NUMBER,E_MAIL,RECIEVER_SENDER,CITY_ID)
values (l_cust_id.nextval,s_name,s_address,s_phone,s_mobile,s_email,'s',v_s_cityid);
close GET_S_CITYID;
SELECT CUST_ID
into s_custid
FROM (select * from L_CUSTOMER ORDER BY CUST_ID DESC)
WHERE rownum <2;
open GET_R_CITYID;
fetch GET_R_CITYID into v_r_cityid;
if GET_R_CITYID%notfound then
insert into L_CITY(CITY_ID,CITY_NAME)
values (l_city_id.nextval,r_city);
end if;
insert into L_CUSTOMER(CUST_ID,CUST_NAME,ADDRESS,PHONE_NUMBER,MOBILE_NUMBER,E_MAIL,RECIEVER_SENDER,CITY_ID)
values (l_cust_id.nextval,r_name,r_address,r_phone,r_mobile,r_email,'r',v_r_cityid);
close GET_R_CITYID;
SELECT CUST_ID
into r_custid
FROM (select * from L_CUSTOMER ORDER BY CUST_ID DESC)
WHERE rownum <2;
commit;
end;
how can i return the value of s_custid and r_custid...
i have to get output. ..
is my procedure right ??
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Jan 03 07:43:52 CST 2025
|