Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Informix - Delete temp table if exists

Tags:

sql

informix

I'm trying to delete a temp table when I run a query. I cannot find the answer and already searched for documentation.

Basically, what I want to do is check if a table exists; if it does exist, delete it and proceed with the select so that the results can be inserted into the temp table. If it doesn't exist, well, just create the TEMP table so that the results can be inserted.

I'm using Informix 11.70

like image 692
gmwill934 Avatar asked Mar 13 '23 10:03

gmwill934


1 Answers

If it is supported in 11.70 (it is in 12.10), then the syntax is:

 DROP TABLE IF EXISTS temp_table_name;

The 11.70 manual for DROP TABLE indicates that it exists in 11.70 as well as 12.10.

Then run your query with the INTO TEMP temp_table_name clause to recreate the table.

like image 157
Jonathan Leffler Avatar answered Mar 16 '23 15:03

Jonathan Leffler