Reputation: 1035
I try to Execute the following:
IF NOT EXISTS (select * from IT_IMAGES where IT_CODE='8717163044612')
BEGIN
INSERT INTO IT_IMAGES (LARGE_IMG,SMALL_IMG,IT_CODE,LAN_CODE) VALUES ('7290011051310.jpg','7290011051310.jpg','8717163044612','1')
END
But I keep getting ORA-00900: invalid SQL statement . Can you help me fix this?
Upvotes: 0
Views: 1877
Reputation: 1269763
The following should work for you:
INSERT INTO IT_IMAGES(LARGE_IMG, SMALL_IMG, IT_CODE, LAN_CODE)
SELECT '7290011051310.jpg', '7290011051310.jpg', '8717163044612', '1'
FROM dual
WHERE NOT EXISTS (SELECT 1 FROM IT_IMAGES WHERE IT_CODE = '8717163044612');
As I think about it, I haven't used if
except in begin
/end
statements in Oracle. You may need a programming block to use if
(MySQL does require this). The above should fix the problem, though.
Here is an example of it working in SQL Fiddle.
Upvotes: 1