? Implicit Cursors

Implicit Cursors

Top  Previous  Next

Implicit Cursors, i.e. the ones that are not declared.

 

DECLARE

v_cust-name varchar2(30);

BEGIN

SELECT cust_name

   INTO v_cust-name

   FROM customer

   WHERE cust_id = 1 ;

DBMS_OUTPUT.PUT_LINE(v_cust-name );

END

DEFINE VARIABLE v_cust-name AS CHARACTER.

 

FIND customer WHERE cust_id = 1.

ASSIGN v_cust-name = cust_name.

 

 

DISPLAY v_cust-name.

 

 

Basically implicit cursor is an Embedded SQL statement. SELECT, INSERT, UPDATE and DELETE could be used. Since implicit cursor works with individual variables only, the select statement should return one and only one row. It is similar to Progress FIND.

It is good practice to check that SELECT returns one row only in exception handling, like we do “IF NOT AVAILABLE customer” in progress.