Last active
August 29, 2015 13:56
-
-
Save peterbe/9004593 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH | |
update_graphics_device AS ( | |
UPDATE graphics_device | |
SET | |
adapter_name = 'Unknown Webcam Pro 9000', | |
vendor_name = 'Logitech Inc.' | |
WHERE | |
vendor_hex = '0x1002' | |
AND | |
adapter_hex = '0x0166' | |
RETURNING 1 | |
), | |
insert_graphics_device AS ( | |
INSERT INTO | |
graphics_device | |
(vendor_hex, adapter_hex, vendor_name, adapter_name) | |
SELECT | |
'0x1002' AS vendor_hex, | |
'0x0166' AS adapter_hex, | |
'Logitech Inc.' AS vendor_name, | |
'Unknown Webcam Pro 9000' AS adapter_name | |
WHERE NOT EXISTS ( | |
SELECT * FROM graphics_device | |
WHERE | |
vendor_hex = '0x1002' | |
AND | |
adapter_hex = '0x0166' | |
LIMIT 1 | |
) | |
RETURNING 2 | |
) | |
SELECT * FROM update_graphics_device UNION ALL SELECT * FROM insert_graphics_device; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment