Plssfunc

SQL> create or replace function route
2 (
3 p_no number
4 )
5 return number
6 is
7 l_res number(20);
8 cursor c1 is
9 select 'x' from dlo where order_no=p_no
10 and
11 qty_ord>nvl(qty_rec,0);
12 cursor c2 is
13 select 'x' from dlo where order_no=p_no
14 and
15 qty_ord=nvl(qty_rec,0);
16 begin
17 open c1;
18 fetch c1 into l_res;
19 if c1%found then
20 open c2;
21 fetch c2 into l_res;
22 if c2%found then
23 close c2;
24 return 0;
25 end if;
26 close c2;
27 close c1;
28 return 1;
29 end if;
30 close c1;
31 end;
32 /
Function created.
SQL> var x number
SQL> exec :x:=route(447350)
BEGIN :x:=route(447350); END;
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "P01.ROUTE", line 18
ORA-06512: at line 1

As far as I can see, the 2 cursors are identical:
cursor c1 is
select 'x' from dlo
where order_no=p_no
and
qty_ord>nvl(qty_rec,0);
c2 is
3          select 'x' from dlo
where order_no=p_no
d
15               qty_ord=nvl(qty_rec,0);Which would make:
if c1%found then
     open c2;
     fetch c2 into l_res;
     if c2%found then
          return 0 ;
     ELSE
return 1 ; --THIS line unreachable since if
since if c1 is found then c2 HAS to be found (they're
both the same)
     end if;
I have to ask the OP, what are you REALLY trying to
do. Is this just an academic exercise? What is the
purpose (note I'm not asking what the end result will
be, I'm asking what the purpose is)Hi JS1,
I wonder have you read the complete post or just jumped into conclusion after reading
the first post.
As far as I can see, the 2 cursors are identical: No they are not identical.
8 cursor c1 is
9 select 'x' from dlo where order_no=p_no
10 and
11 qty_ord>nvl(qty_rec,0);
12 cursor c2 is
13 select 'x' from ordloc where order_no=p_no
14 and
15 qty_ord=nvl(qty_rec,0);.............
- SK

Similar Messages

Maybe you are looking for

  • Error - Can't open more than one image in CS3

    My Photoshop CS3 was working fine until all of a sudden it no longer lets me open more than one image at a time without crashing. Anyone else have this problem? How do I fix it?

  • How to use a jar from a external library DC Project?

    I followed the steps of how to create DC, External Library Project, which contains the jar I want. I understood that this type of project can't be deployed so I build and deployed other DC Project from the type J2EE server component Library and added

  • Pdf pack will not create a pdf from a tiff file    conversion failure    Why

    pdf pack will not create a pdf from a tiff file    conversion failure    Why

  • File a complaint, poor customer service

    I have been a loyal customer with Verizon since before 2005. I have two wireless plans with seven phones, home phone, dsl, two business line and Verizon will not take care of my service correctly. I am very disappointed. In July 2011, I purchased two

  • Bug in OS6 for Bluetooth connection

    My BB 9700  cnnected fine with my handsfree carkit when I used OS5. After going to OS6 the connection with my carkit always gave troubles. I've experienced that after a reload of the OS (battery out and in again) the conection works fine one time. Af