在POSTGRESQL中插入条件

时间:2014-08-12 05:52:13

标签: postgresql

如果AND EntityType = 1000000那么,我不想执行下面的查询。请更正

INSERT INTO AD_EntityType (AD_Client_ID,AD_EntityType_ID,AD_Org_ID,Created,CreatedBy,Description,EntityType,IsActive,Name,Processing,Updated,UpdatedBy) 
 VALUES (0,1000000,0,TO_TIMESTAMP('2013-07-05 15:05:13','YYYY-MM-DD HH24:MI:SS'),100,'Human Resource Management System','H','Y','HR','N',
 TO_TIMESTAMP('2013-07-05 enter code here15:05:13','YYYY-MM-DD HH24:MI:SS'),100)

1 个答案:

答案 0 :(得分:1)

也许你需要这样的东西:

INSERT INTO AD_EntityType (AD_Client_ID,AD_EntityType_ID,AD_Org_ID,Created,CreatedBy,Description,EntityType,IsActive,Name,Processing,Updated,UpdatedBy) 
SELECT 0,1000000,0,TO_TIMESTAMP('2013-07-05 15:05:13','YYYY-MM-DD HH24:MI:SS'),100,'Human Resource Management System','H','Y','HR','N',TO_TIMESTAMP('2013-07-05 enter code here15:05:13','YYYY-MM-DD HH24:MI:SS'),100
WHERE NOT EXISTS(SELECT * FROM AD_EntityType WHERE AD_EntityType_ID = 1000000)

如果您的表格中包含AD_EntityType_ID = 1000000值,则不会插入数据。