If a procedure dynamically creates and then selects the same temporary table within a stored procedure, you must use the EXECUTE IMMEDIATE WITH RESULT SET ON syntax to avoid “Column not found” errors. For example:
CREATE PROCEDURE p1 (IN @t varchar(30)) BEGIN EXECUTE IMMEDIATE 'SELECT * INTO #resultSet FROM ' || @t; EXECUTE IMMEDIATE WITH RESULT SET ON 'SELECT* FROM #resultSet'; END
This was omitted from Chapter 8, “Using Procedures and Batches,” Sybase IQ System Administration Guide.