Oracle Programming language not found cursor

Asked By 0 points N/A Posted on -
qa-featured

In what order should a open/fetch/loop set of commands in a PL/SQL block be implemented if you use the %NOTFOUND cursor variable in the exit when statement? Why?

SHARE
Answered By 0 points N/A #82051

Oracle Programming language not found cursor

qa-featured

PL/SQL block should be implemented in proper manner otherwise it will generate error and will not execute. Here i have given example below just try to understand it.

DECLARE
v_NewMajor VARCHAR2(10) := 'History';
firstName VARCHAR2(10) := 'Scott';
v_LastName VARCHAR2(10) := 'Urman';
BEGIN
UPDATE lecturer
SET major = v_NewMajor
WHERE first_name = firstName
AND last_name = v_LastName;
IF SQL%NOTFOUND THEN
INSERT INTO lecturer (ID, first_name, last_name, major)
VALUES (20001, firstName, v_LastName,
v_NewMajor);
END IF;
END;

Here what above code will do is? There are four blocks DECLARE,BEGIN,EXCEPTION and END. We have to declare variable in DECLARE section, BEGIN will contain SQL statement, EXCEPTION will contain exception that must be handle by the procedure and at last END will inform that the procedure will end.

Related Questions