cancel
Showing results for 
Search instead for 
Did you mean: 

Temp table problem in ASA 12 . SQLE_TEMP_TABLE_DEFINITION_CHANGED

Former Member
5,307

Hi / I got this error after moving to asa 12 from asa 10 . Recompile of all procedure did not help . Store procedure just failing from time to time ( in 20 % cases on the different data ) / Can anybody help ? Error reference suggest to recompile procedures . It dos not help . Thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member

If you use a temporary table inside a procedure and there is a chance that the table definition is different in each procedure call, then you must use the temporary table with execute immediate statements only (e.g EXECUTE IMMEDIATE WITH RESULT SET ON "select * from tmp2"). All procedure statements except "execute immediates" are parsed and annotated when they are used the first time. So a "select * from tab2" has a fixed parse tree after the 1st run and if the table definition is different during the next procedure call you see the error. Hope this helps.

Former Member
0 Kudos

I add this post only because of the error code. We are migrating from SQLA7 to 12 and get the same error now when calling a stored procedure twice. The second run causes the error. Imagine the following: 1. Create some data into #temptable1_first 2. Now group this data by "select col1,sum(col2) as col2 into #temptable1 from #temptable1_first group by col1"

The problem here is that the column types of col1 and col2 are not well-defined (although #temptable1_first has data in both calls). To avoid this problem you have to make sure that the column types are known before grouping the data:

Select cast(null as integer) as col1, cast(null as integer) as col2 into #temptable1; delete from #temptable1; insert into #temptable1 select... from #temptable1_first;