DARTHTAMPON
11-05-2008, 03:41 PM
I have this sp
create procedure test()
DEFINE minRelease INTEGER;
DEFINE currentRelease INTEGER;
DEFINE box varchar(25);
DEFINE boxes varchar(200);
CREATE TEMP TABLE osRelease (currentRelease INTEGER, boxes varchar(200))
WITH NO LOG;
select beginning_release into minRelease from dus_cfg;
foreach cur1 for select distinct(relnum) into currentRelease from releases
where relnum > minRelease order by relnum
foreach cur2 for select distinct(mach_type) into box from update
where relnum = currentRelease
let boxes = boxes + box + ',';
END FOREACH;
insert into osRelease values (currentRelease, boxes);
END FOREACH;
select r.relnum, r.reldes, o.boxes,
case r.status
when -1 then 'none
when 4 then 'four
else ''
end
from releases r, osRelease where o.release = r.relnum;
# ^
# 659: INTO TEMP table required for SELECT statement.
#
end procedure
When I run I get this error,
-659 INTO TEMP table required for SELECT statement.
A SELECT statement did not specify where to put the returned values.
SELECT statements within a procedure require either an INTO TEMP clause
or an INTO clause that references the appropriate procedural
variables.
Example of error:
CREATE PROCEDURE testproc()
...
SELECT col1, col2 FROM tab; -- error
END PROCEDURE
Correction:
CREATE PROCEDURE testproc()
...
SELECT col1, col2 INTO var1, var2 FROM tab;
SELECT col1, col2 FROM tab INTO TEMP another_table;
END PROCEDURE
So looking at other SP's I see that informix requires return values (not sure if this is entirly true). Is there a way for me to return a dynamic select via a stored procedure in informix? This set of data could have between 10 and 10000 rows.
create procedure test()
DEFINE minRelease INTEGER;
DEFINE currentRelease INTEGER;
DEFINE box varchar(25);
DEFINE boxes varchar(200);
CREATE TEMP TABLE osRelease (currentRelease INTEGER, boxes varchar(200))
WITH NO LOG;
select beginning_release into minRelease from dus_cfg;
foreach cur1 for select distinct(relnum) into currentRelease from releases
where relnum > minRelease order by relnum
foreach cur2 for select distinct(mach_type) into box from update
where relnum = currentRelease
let boxes = boxes + box + ',';
END FOREACH;
insert into osRelease values (currentRelease, boxes);
END FOREACH;
select r.relnum, r.reldes, o.boxes,
case r.status
when -1 then 'none
when 4 then 'four
else ''
end
from releases r, osRelease where o.release = r.relnum;
# ^
# 659: INTO TEMP table required for SELECT statement.
#
end procedure
When I run I get this error,
-659 INTO TEMP table required for SELECT statement.
A SELECT statement did not specify where to put the returned values.
SELECT statements within a procedure require either an INTO TEMP clause
or an INTO clause that references the appropriate procedural
variables.
Example of error:
CREATE PROCEDURE testproc()
...
SELECT col1, col2 FROM tab; -- error
END PROCEDURE
Correction:
CREATE PROCEDURE testproc()
...
SELECT col1, col2 INTO var1, var2 FROM tab;
SELECT col1, col2 FROM tab INTO TEMP another_table;
END PROCEDURE
So looking at other SP's I see that informix requires return values (not sure if this is entirly true). Is there a way for me to return a dynamic select via a stored procedure in informix? This set of data could have between 10 and 10000 rows.