0

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
Valdas
  • 368
  • 4
  • 14
  • I know this has already been answered , but if you need to know more about SQLBase, here is a link to some manuals for every version from v8 thru v12.1 : http://samples.tdcommunity.net/index.php?dir=SqlBase/SqlBase_Books/ – Steve Leighton Jul 20 '18 at 01:52

1 Answers1

1

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()
Steve Leighton
  • 790
  • 5
  • 15