PL/SQL Delete

Oracle PL/SQL Delete Example

Example 1:

DELETE FROM customers c 
WHERE c.customer_type='INDIVIDUAL' 
AND c.city = 'NEW YORK';

Example 2:

DECLARE
	c customers%ROWTYPE;
BEGIN
	SELECT * INTO c 
	FROM customers 
	WHERE customer_id = 123001; 
	
	DELETE FROM customers 
	WHERE customer_id = c.customer_id;  
	DBMS_OUTPUT.PUT_LINE('The customer '||c.customer_name||' has been deleted');
	
	COMMIT;
	
	EXCEPTION
		WHEN OTHERS THEN
		DBMS_OUTPUT.PUT_LINE(SQLERRM);
		ROLLBACK;
END;