28th Example - Implicit Cursor on PL/SQL

Implicit cursor is a cursor that was made on the contents of PL/SQL block and can only do 1 unit record processing. Unlike explicit cursors, implicit cursor does not contain CURSOR statement on its block.
Here is an example of using implicit cursor (SELECT INTO) in the PL / SQL block:

DECLARE
v_nim TMahasiswa.NIM%TYPE;
v_nama TMahasiswa.NAMA%TYPE;
BEGIN
SELECT nim, nama INTO v_nim, v_nama FROM tmahasiswa WHERE nim='MI1001';
DBMS_OUTPUT.PUT_LINE (v_nim);
DBMS_OUTPUT.PUT_LINE (v_nama);
END;
/


Block PL/SQL above has an implicit cursor form of SELECT ... INTO statement. Implicit cursor placed is under the BEGIN statement. Conducted by the implicit cursor is retrieving data nim and nama of the table tmahasiswa to be stored in the variable v_nim and v_nama. WHERE syntax on the implicit cursor used to restrict only 1 record that will be processed by an implicit cursor. The results are then displayed to the screen with dbms_output.put_line statement.

No comments

Powered by Blogger.