I have this:
declare
toStoreA varchar2(10);
toStoreB varchar2(10);
toStoreC varchar2(10);
cursor c1 is
select a, b, c
from table1
where login = 'myLogin';
begin
open c1;
fetch c1 into toStoreA,
toStoreB,
toStoreC
close c1;
if toStoreB = NULL then
dbms_output.put_line('OK, we are in if, toStoreB is null');
end if;
dbms_output.put_line('toStoreA:' || toStoreA || '_');
dbms_output.put_line('toStoreB:' || toStoreB || '_');
dbms_output.put_line('toStoreC:' || toStoreC || '_');
end;
My target is to detect if fetch cursor returned no value.
If I will query my sql statement in sql window I will get this:
> select a, b, c from table1 where login = 'myLogin';
++++++++++++++++++++++++++++++++++++++++++++
+ some val + + +
++++++++++++++++++++++++++++++++++++++++++++
This is what I get in DBMS Output window:
toStoreA:some val_
toStoreB:_
toStoreC:_
As you see, I don't get string OK, we are in if, toStoreB is null in DBMS Output. Why? Well, obvious if is not passed. The question is how to correctly check if fetch cursor returned null value (no value)?
I'd also tried if toStoreB = '' then but it didn't help.
Aucun commentaire:
Enregistrer un commentaire