I am quite new to SQLBase and I've been struggling for a couple of days now, is it possible to write an IF statement in a standalone script? Something like:
IF EXISTS (SELECT * FROM SYSADM.SYSTABLES WHERE NAME = 'TMP') THEN
DROP TABLE TMP
END
or
IF NOT EXISTS (SELECT * FROM SYSADM.SYSTABLES WHERE NAME = 'TMP') THEN
CRETE TABLE TMP ...
END
Store a simple procedure , and run it from SQLTalk or TeamDeveloper . Optionally send in the Table name as a parameter and run it with 'Execute SYSADM.MyProc \TMP/ ' , or store the Proc with no parameters and hardcode the Table Name, and simply 'Execute SYSADM.MyProc'
ps Dont forget the SqlClearImmediate() !
store MyProc
PROCEDURE: table_proc static
PARAMETERS:
String: psTableName
Local Variables
Boolean: bExists
Actions
On Procedure Startup
If SqlExists('Select 1 from SYSADM.SYSTABLES where Name = :psTableName' , bExists )
If bExists
Call SqlImmediate('Drop table TMP')
Else
Call SqlImmediate('Create Table TMP(col1 int )' )
Call SqlClearImmediate()