Unix Technical Forum

Is this an Informix bug?

This is a discussion on Is this an Informix bug? within the Informix forums, part of the Database Server Software category; --> I had a typo in an SQL query, and I stumbled upon an interesting feature/bug. Try this code: create ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 04:33 PM
Zachi
 
Posts: n/a
Default Is this an Informix bug?

I had a typo in an SQL query, and I stumbled upon an interesting
feature/bug. Try this code:

create table tab(a int);
create table tab1(a int);
insert into tab values(1);
insert into tab values(null);
select count(*) from tab where tab is not null;
select count(*) from tab where tab is null;
select count(*) from tab where tab1 is null;

The answers are:
2
0
SQL Error -217 (column not found)

which behaves as if Informix evaluates tab is null to false, tab is
not null to true and a different table name is considered an error. Is
there a documented (or even undocumented) meaning for use of the table
name in a WHERE clause using IS NULL and IS NOT NULL or is this a bug?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 04:33 PM
Carsten Haese
 
Posts: n/a
Default Re: Is this an Informix bug?

On Tue, 2007-05-08 at 11:26 -0700, Zachi wrote:
> I had a typo in an SQL query, and I stumbled upon an interesting
> feature/bug. Try this code:
>
> create table tab(a int);
> create table tab1(a int);
> insert into tab values(1);
> insert into tab values(null);
> select count(*) from tab where tab is not null;
> select count(*) from tab where tab is null;
> select count(*) from tab where tab1 is null;
>
> The answers are:
> 2
> 0
> SQL Error -217 (column not found)
>
> which behaves as if Informix evaluates tab is null to false, tab is
> not null to true and a different table name is considered an error. Is
> there a documented (or even undocumented) meaning for use of the table
> name in a WHERE clause using IS NULL and IS NOT NULL or is this a bug?


It's a feature. IDS accepts the name of a table as an expression. This
expression constructs ROW objects on the fly, containing all columns of
the table. Try "select tab from tab" to see what that does. What that's
good for, well, your guess is probably just as good as mine.

HTH,

--
Carsten Haese
http://informixdb.sourceforge.net


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-20-2008, 04:34 PM
Art S. Kagel
 
Posts: n/a
Default Re: Is this an Informix bug?

Carsten Haese wrote:
> On Tue, 2007-05-08 at 11:26 -0700, Zachi wrote:
>
>>I had a typo in an SQL query, and I stumbled upon an interesting
>>feature/bug. Try this code:
>>
>>create table tab(a int);
>>create table tab1(a int);
>>insert into tab values(1);
>>insert into tab values(null);
>>select count(*) from tab where tab is not null;
>>select count(*) from tab where tab is null;
>>select count(*) from tab where tab1 is null;
>>
>>The answers are:
>> 2
>> 0
>> SQL Error -217 (column not found)
>>
>>which behaves as if Informix evaluates tab is null to false, tab is
>>not null to true and a different table name is considered an error. Is
>>there a documented (or even undocumented) meaning for use of the table
>>name in a WHERE clause using IS NULL and IS NOT NULL or is this a bug?


IDS 7.31:

select sec_desc2 from sec_desc2;
SQL -217: Column (sec_desc2) not found in any table in the query (or SLV is
undefined).
SQLSTATE: IX000 at /dev/stdin:1

IDS 10.00:

select sec_desc2 from sec_desc2;

-- no output.

Art S. Kagel

> It's a feature. IDS accepts the name of a table as an expression. This
> expression constructs ROW objects on the fly, containing all columns of
> the table. Try "select tab from tab" to see what that does. What that's
> good for, well, your guess is probably just as good as mine.
>
> HTH,
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-20-2008, 04:34 PM
Art S. Kagel
 
Posts: n/a
Default Re: Is this an Informix bug?

Carsten Haese wrote:
> On Tue, 2007-05-08 at 11:26 -0700, Zachi wrote:
>
>>I had a typo in an SQL query, and I stumbled upon an interesting
>>feature/bug. Try this code:
>>
>>create table tab(a int);
>>create table tab1(a int);
>>insert into tab values(1);
>>insert into tab values(null);
>>select count(*) from tab where tab is not null;
>>select count(*) from tab where tab is null;
>>select count(*) from tab where tab1 is null;
>>
>>The answers are:
>> 2
>> 0
>> SQL Error -217 (column not found)
>>
>>which behaves as if Informix evaluates tab is null to false, tab is
>>not null to true and a different table name is considered an error. Is
>>there a documented (or even undocumented) meaning for use of the table
>>name in a WHERE clause using IS NULL and IS NOT NULL or is this a bug?


IDS 7.31:

select sec_desc2 from sec_desc2;
SQL -217: Column (sec_desc2) not found in any table in the query (or SLV is
undefined).
SQLSTATE: IX000 at /dev/stdin:1

IDS 10.00:

select sec_desc2 from sec_desc2;

-- no output.

Art S. Kagel

> It's a feature. IDS accepts the name of a table as an expression. This
> expression constructs ROW objects on the fly, containing all columns of
> the table. Try "select tab from tab" to see what that does. What that's
> good for, well, your guess is probably just as good as mine.
>
> HTH,
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:34 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com