I am trying to write a simple cursor and run it inside the command line Oracle client on Unix, SQL Plus. I have mostly been using single line statements and can't find a way to execute a multi line statement once I am done writing it. Can anybody help?
Here is my code:
DECLARE
TYPE array_t IS varray(4) OF varchar2(10);
ARRAY array_t := array_t('foo', 'bar', 'stack', 'overflow');
BEGIN
FOR i IN 1..array.count loop
dbms_output.put_line(array(i));
END loop;
END;
Thanks
To execute a PL/SQL block in SQL*PLUS, add slash at the end of the PL/SQL block:
SQL> DECLARE
2 TYPE array_t IS varray(4) OF varchar2(10);
3 ARRAY array_t := array_t('foo', 'bar', 'stack', 'overflow');
4 BEGIN
5 FOR i IN 1..array.count loop
6 dbms_output.put_line(array(i));
7 END loop;
8 END;
9 /
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With