Sunday, 9 June 2013

PL/SQL program to show GOTO statement

CREATE TABLE MyTable29( num_col  NUMBER,char_col   VARCHAR2(60));

PL\SQL Block:

DECLARE
      v_Counter  BINARY_INTEGER := 1;
    BEGIN
      LOOP
       INSERT INTO MyTable29
         VALUES (v_Counter, 'Loop count');
       v_Counter := v_Counter + 1;
       IF v_Counter > 50 THEN
         GOTO l_EndOfLoop;
       END IF;
     END LOOP;

     <<l_EndOfLoop>>
     INSERT INTO MyTable29 (char_col)
       VALUES ('Done!');
   END;

No comments:

Post a Comment