Use a subquery to test for the existence of rows.
Syntax EXISTS subquery NOT EXISTS subquery Key subquery A restricted SELECT statement. (The COMPUTE clause and the INTO keyword are not allowed.)
IF EXISTS (select *
where customer_id = 123)
Print 'Record exits'
Print 'Record doesn''t exist' SELECT sal.sales_id
FROM Sales AS sal
WHERE NOT EXISTS
FROM Discounts AS disc
WHERE sal.sales_id = disc.sales_id );
“If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim...” - Rudyard Kipling 1899
Equivalent Oracle command:
Select into a cursor then: IF SQL%FOUND THEN...