0

If AD_EntityType =1000000 then, i dont want to execute below query . please correct it

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)
2
  • did you write the query in postgresql function or front end Commented Aug 12, 2014 at 6:01
  • Are you attempting to write code that does an "insert if not exists" operation? i.e. "Create EntityType with id=1000000 only if it does not already exist" ? Commented Aug 12, 2014 at 6:18

1 Answer 1

1

Perhaps you need something like this:

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)

The data is not inserted in case you have the AD_EntityType_ID = 1000000 value in your table.

Sign up to request clarification or add additional context in comments.

1 Comment

There will be no errors with this query even if the value exists

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.