Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
Sharing a temporary table between procedures can cause problems if the table definitions are inconsistent. For example, suppose you have two procedures procA and procB, both of which define a temporary table, temp_table, and call another procedure called sharedProc. Neither procA nor procB has been called yet, so the temporary table does not yet exist.
Now, suppose that the procA definition for temp_table is slightly different than the definition in procB—while both used the same column names and types, the column order is different.
When you call procA, it returns the expected result. However, when you call procB, it returns a different result.
This is because when procA was called, it created temp_table, and then called sharedProc. When sharedProc was called, the SELECT statement inside of it was parsed and validated, and then a parsed representation of the statement was cached in case the SELECT statement is executed again. The cached version reflects the column ordering from the table definition in procA.
Calling procB causes the temp_table to be recreated, but with different column ordering. When procB calls sharedProc, the database server uses the cached representation of the SELECT statement. Consequently, the results are different.
You can avoid this from happening by doing one of the following:
|Send feedback about this page via email or DocCommentXchange||Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0|