Here is a simple implementation to perform ‘IF EXISTS’ check
PL/SQL:
DECLARE vCount NUMBER; BEGIN SELECT COUNT(*) INTO vCount FROM TABLE_NAME WHERE COLUMN_NAME = 'YOUR_VALUE'; IF vCount > 0 THEN /* Exists */ DBMS_OUTPUT.PUT_LINE('Exists'); ELSE /* Not exists */ DBMS_OUTPUT.PUT_LINE('Does not exists'); END IF; END;
Leave a Reply