Re: Informix bug???
Posted in 1998
Alexander V.Didytch wrote:
>
> Jonathan Leffler wrote:
>
> > It sounds like a bug, but we need to know a good deal more before
> > deciding. For starters, which version of OnLine or SE are you using?
> > On which platform?
>
> Be sure, its a bug -- we are using Informix 7.3TC3 on WinNt4.0
Be careful with such statements :)
>
> and the following script
What you are describing is completely different from the original
Florin's problem, and it is not a bug, it is "behavior by design".
RTFM.
>
> create procedure check ()
> returning char(20);>
> define name char(20);
>
> let name = 'AAAAA';
> LET name = (SELECT name from code_table where code=1);
This is the same as:
LET name = (SELECT 'AAAAA' from code_table where code=1);
> return name;
> end procedure;
>
> execute procedure check() -- returns 'AAAAA'
It should return 'AAAAA' because query returns constant accepted
from the procedure's variable "name", not value of table_code's
column "name"
>
> while executing
>
> SELECT name from code_table where code=1 returns value that differ ;)
Of course, it returns the exact value of the column "name"
>
> It's a reproducible error.
Agree, it's a reproducible programmer's error.
>
> SY, Alexander
> --
> Alexander V.Didytch, Kyiv, Ukraine
> --
> "The truth will make you free, but first it will make you miserable"
> -- Tom DeMarco
Yes, read the following,
from "Guide to SQL - Tutorial" v7.2, page 12-22 :
...
Variables and Column Names
If you use the same identifier for a procedural variable as you use
for a column name, the database server assumes that each instance
of the identifier is a variable. Qualify the column name with the
table name to use the identifier as a column name. In the following
example, the procedure variable lname is the same as the column name.
In the following SELECT statement, customer.lname is a column name,
and lname is a variable name:
CREATE PROCEDURE table_test()DEFINE lname CHAR(15);
LET lname = 'Miller';
.
.
.
SELECT customer.lname FROM customer INTO lname
WHERE customer_num = 502;.
.
...
Best regards,
Mladen
--
----------------------------------------------------------------------
Mladen Jovanovski E-mail: mladen@ultra.com.mk
ULTRA Computing, Ltd. Phone/Fax: +389 91 36 26 36
Partizanski odredi 70b
P.O.Box 798
91000 Skopje
Macedonia, Europe
----------------------------------------------------------------------