Re: Detecting TEMP tables .... HEEELP! ;-)
Posted in 1999
Klaus Mueller wrote: > > Hi; > look in systabnames of sysmaster-database. > > Richard Auslander wrote: > > > In a stored procedure, using Dynamic Server 7.30 (thought it shouldn't > > matter), how can I tell if a temp table already exists? This is an > > age-old Informix problem, where it's an error if you create a table that > > already exists, and an error if you delete one that doesn't ... you > > can't win, and all I want to do is delete it if it exists. Kind of like > > Oracle's "CREATE OR REPLACE" <grin>. Any help would be much > > appreciated. BTW, I hunted through 'systables' (the obvious solution), > > and temp tables are not included there, or anywhere else to my > > knowledge. Thanks! Klaus' suggestion to look in sysmaster:systabnames should work. However, while it is not possible to trap the CREATE TABLE error in a stored procedure, drop the offending table and return to the CREATE TABLE code; you can do the opposite. Always DROP TABLE the temp table then put in an error trap for the NO SUCH TABLE error and suppress it. That is clean and simple and fast. Art S. Kagel