Answer to Question #252276 in Databases | SQL | Oracle | MS Access for Tarurendra Kushwah

Question #252276

Write a program in PL/SQL to show the uses of SQL%FOUND to determine if a DELETE statement affected any rows.


1
Expert's answer
2021-10-17T01:45:28-0400
DROP TABLE student_temp;
CREATE TABLE student_temp AS
  SELECT student_id, first_name, last_name 
  FROM student;
 
CREATE OR REPLACE PROCEDURE test_proc (
  z_stu_id NUMBER
) AUTHID DEFINER AS
BEGIN
  DELETE FROM stu_temp
  WHERE student_id = z_stu_id;
 
  IF SQL%FOUND THEN
    DBMS_OUTPUT.PUT_LINE (
      'Delete succeeded for student_id: ' || z_stu_id
    );
  ELSE
    DBMS_OUTPUT.PUT_LINE ('No employee of ID '|| z_stu_id||'is found.');
  END IF;
END;
/
BEGIN
  test_proc(175);
  test_proc(444);
END;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS