table register
key | app |
---|---|
123 | insta |
table inbox
EventSourceApplication | EventName | MessageId(primarykey) | MessageText | status |
---|---|---|---|---|
appointmentbooked | CAR20124 | SUCCESSFULL | ok |
I want to upsert into table inbox only if there is a specific data in table register in this case key = 123 & app = insta
my query is like
INSERT INTO inbox(EventSourceApplication,EventName,MessageId ,MessageText,status)
VALUES ('fb1','appointmentbooked','CAR201246','SUCCESSFULL','nope') ON CONFLICT(MessageId)
DO UPDATE SET EventSourceApplication = EXCLUDED.EventSourceApplication,
EventName = EXCLUDED.EventName,MessageText=EXCLUDED.MessageText
WHERE (SELECT 1 FROM register WHERE key='123' AND app = 'insta')
Is the query wrong ? since i am able to insert into inbox even if wrong data is given