Oracle ‘knows’ which token is a variable and which is a column in a table. This becomes important when you are using a variable whose name clashes with that of a column name in a predicate. Consider the following:
create table tbl (x number)
/
insert into tbl values(1)
/
declare
x number;
d number;
begin
select count(*) into d
from tbl where x > 0;
end;
This compiles fine under Oracle. Oracle ‘knows’ that the x referred to in the query is the column and not the variable. But a similar piece of code under Informix results in ‘-696 Variable () has undefined value’.
create table tbl(x int);
insert into tbl values(1);
create procedure demo_err()
define d, x int;
select count(*) into d
from tbl where x > 0;
end procedure;
call demo_err();
In fact, the Informix guide explicitly states that the local variable takes precedence.
Whose handling is more appropriate? Either way, I feel the IDS folks should throw up easily understandable error – ‘Variable () has undefined value’ spoilt a n00b’s afternoon