我是SQLBase的新手,我已经苦苦挣扎了几天,是否可以在独立脚本中编写IF语句?类似的东西:
IF EXISTS (SELECT * FROM SYSADM.SYSTABLES WHERE NAME = 'TMP') THEN
DROP TABLE TMP
END
或
IF NOT EXISTS (SELECT * FROM SYSADM.SYSTABLES WHERE NAME = 'TMP') THEN
CRETE TABLE TMP ...
END
答案 0 :(得分:1)
存储一个简单的过程,并从SQLTalk或TeamDeveloper运行它。 (可选)将表名作为参数发送,并使用'Execute SYSADM.MyProc \ TMP /'运行它 ,或存储没有参数的Proc并对表名进行硬编码,只需“执行SYSADM.MyProc”
ps不要忘记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()