WITH new_browser AS (
INSERT INTO audit_log.browsers ( agent_string )
SELECT 'test8' WHERE NOT EXISTS (SELECT * FROM audit_log.browsers WHERE agent_string = 'test8')
RETURNING browser_id
)
SELECT * FROM new_browser
UNION
SELECT browser_id FROM audit_log.browsers WHERE agent_string = 'test8'
The only problem is that i have to write the insert item/select condition 3 times, for one particular column...
No comments:
Post a Comment