Download Informix Guide to SQL: Syntax, Version 6.0

Transcript
Identifier
Using CURRENT, DATETIME, INTERVAL, and NULL in INSERT
You cannot use the CURRENT, DATETIME, INTERVAL, or NULL keyword as
the name of a procedure with the INSERT statement.
For example, if you define a variable called null, when you try to insert the
value null into a column, you receive a syntax error. This is shown in the
following example:
CREATE PROCEDURE problem()
.
.
.
DEFINE null INT;
LET null = 3;
INSERT INTO tab VALUES (null); -- error, inserts NULL, not 3
Using NULL and SELECT in a Condition
If you define a variable with the name null or select, using it in a condition that
uses the IN keyword is ambiguous. The following example shows three conditions that cause problems: in an IF statement, in a WHERE clause of a
SELECT statement, and in a WHILE condition:
CREATE PROCEDURE problem()
.
.
.
DEFINE x,y,select, null, INT;
DEFINE pfname CHAR[15];
LET x = 3; LET select = 300;
LET null = 1;
IF x IN (select, 10, 12) THEN LET y = 1; -- problem if
IF x IN (1, 2, 4) THEN
SELECT customer_num, fname INTO y, pfname FROM customer
WHERE customer IN (select , 301 , 302, 303); -- problem in
WHILE x IN (null, 2) -- problem while
.
.
.
END WHILE;
1-480 Syntax