Temporary Tables / ref cursors / Truncate issues with .Net
513282Jul 25 2006 — edited Jul 25 2006Background: We have a .Net application that calls a package/sp for reporting. The columns requested can change by whatever the user selects. For this reason we thought of using a session-only temporary table. As mostly SQLServer programmers, we are used to the way MS does it where the temp table is created by the caller, and immediately upon completion, deletes the temp table. With Oracle, it seems to not truly be a temp table but a table whose contents are session specific and which clears the data from the temp table either by a clean disconnect or "truncate" of the temp table. When the .Net application user calls the procedure, we populate the ref cursor with the results then after completion, calls a procedure in the same package to truncate the temp table to clear what was left in the temp table just in case of a non-clean disconnect. Problem is that it empties the ref cursor so no results are sent back to .Net app.
Question: How can we truncate the table after use and NOT lose the result set?? Is there a better way to create variable columned temporary tables (similar to how MS does it?)