Not All Variable Bound (merged 3) [message #403667] |
Mon, 18 May 2009 00:18 |
sajidrazmi
Messages: 47 Registered: August 2008 Location: oman
|
Member |
|
|
Hi Dear All,
I am getting one error when i am going to execute this Procedure,
Declare
Cursor C1 Is
Select Emp_Comp_Code,Emp_Code,Emp_Name,Emp_Join_Dt
From Asg_Sm_Emp_Key
Where Emp_Comp_Code ='001'
And Nvl(Emp_End_Of_service_Yn,'N') ='N'
Order By To_Number(Emp_Code);
Cursor C2 (Emp_Join_Dt In Date) Is
Select Years,Trunc(Mb-Years*12)Months,Nd-Add_Months(Od,Trunc(MB))Days
From
(Select Od,Nd,Months_Between(Nd,Od) Mb,Trunc(Months_Between(Nd,Od)/12) Years
(select Sysdate Nd,Sysdate-fd Od From
(Select (Trunc(sysdate) - (:Emp_Join_Dt)) Fd From Dual)));
C2_Row C2%Rowtype;
Begin
For I In C1 Loop
IF C2%Isopen Then Close C2; End If;
Open C2(I.Emp_Join_Dt);
Loop
Fetch C2 Into C2_Row;
Exit When C2%Notfound;
Insert Into Temp_Test (Comp_Code,Emp_Code,Emp_Name,Dt_Date,Nu_Year,Nu_Mon
Values (I.Emp_Comp_Code,I.Emp_Code,I.Emp_Name,Sysdate,C2_Row.Years,C2_Ro
End Loop;
Close C2;
End Loop;
End;
ORA-01008: not all variables bound
|
|
|
|
|
|
|
|
|
|
Re: Not All Variable Bound [message #403687 is a reply to message #403686] |
Mon, 18 May 2009 01:46 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
That is not what I asked. I asked why you chose to get them through a cursor, where you could just as well do it using simple assignment. It would make it more readable as well.
Now, about your error: You cannot refer to Od in the part where you calculate Years; the two are siblings and do not see each other
|
|
|
Re: Not All Variable Bound [message #403693 is a reply to message #403677] |
Mon, 18 May 2009 02:00 |
joicejohn
Messages: 327 Registered: March 2008 Location: India
|
Senior Member |
|
|
@sajidrazmi,
sajidrazmi wrote on Mon, 18 May 2009 11:23 | Thanks For Reply
But if u wrote this code it give you error
Invalid Identifier;
|
I didn't quiet understand why @bonker's solution didn't work for you. That sounded the possible cause.
ORA-01008 not all variables bound
Cause: A SQL statement containing substitution variables was executed without all variables bound. All substitution variables must have a substituted value before the SQL statement is executed.
Action: In OCI, use an OBIND or OBINDN call to substitute the required values.
If you could have read the Posting Guidelines @Swan had asked and posted a Test Case then your problem could have been much more easier to understand.
Regards,
Jo
|
|
|
|