• Welcome, Guest. Please login.
May 26, 2019, 05:43:16 am


Welcome to the SQLitening support forums!

Create Table If Not Exists - Question

Started by Peter Presland, January 04, 2009, 12:24:39 pm

Previous topic - Next topic

Peter Presland

I need to test if table creation was successful or not. Documentation simply says that a 'No-op' occurs if the table already exists which is not an error, and I can find no further reference to it.

So, question: How do I test for the 'No-op' condition immediately following the Create command?

Fred Meier

I know of no way to check for the 'No-op' condition when using 'If Not Exists'.

Here are two ways you could consider to accomplish same thing:
1. Get list of table names using slGetTableNames and check if your table is in list.
2. Do the Create not using the 'If Not Exists' and have any error returned to you.

Peter Presland

Thanks once again Fred.

I'm making serious progress with both this and PB9 now. It's getting easier  :)

Fred Meier

Here is another way to tell if a table exist.
   slSel "Pragma table_info(TableName)"
   if slGetRow(0, "C") then
      ' table exists
      ' table does not exist
   end if

Peter Presland

Thanks Fred

I've already implemented a work around per your last post but useful to have the pragma command pointed out.

Peter Presland