You do not need to write a stored procedure; you just need to tell IDS which type is NULL. Assuming you are not using IDS 7.31 (which does not support any letter notation), you could write:
SELECT NULL::INTEGER FROM dual; SELECT CAST(NULL AS INTEGER) FROM dual;
And if you don't have dual as a table (you probably don't), you can do one of several things:
CREATE SYNONYM dual FOR sysmaster:"informix".sysdual;
The "sysdual" table was added relatively recently (IDS 11.10, IIRC), so if you are using an older version, it will not be. The following works with any version of IDS - this is what I use.
-- @(#)$Id: dual.sql,v 2.1 2004/11/01 18:16:32 jleffler Exp $ -- Create table DUAL - structurally equivalent to Oracle similarly named table. -- It contains one row of data. CREATE TABLE dual ( dummy CHAR(1) DEFAULT 'x' NOT NULL CHECK (dummy = 'x') PRIMARY KEY ) EXTENT SIZE 8 NEXT SIZE 8; INSERT INTO dual VALUES('x'); REVOKE ALL ON dual FROM PUBLIC; GRANT SELECT ON dual TO PUBLIC;
Idiomatically, if you are going to SELECT from Systables to get a single row, you should include ' WHERE tabid = 1 '; this is the record itself for Systables, and if it is missing, then the fact that your SELECT statement returns any data is the least of your problems. (I never saw this as a mistake.)
source share