Executing a multi line statement in SQL Plus on Unix
10,731
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 /
Related videos on Youtube
Comments
-
amphibient almost 2 years
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
-
amphibient over 11 yearswhat is the difference between that and just typing . ? both seem to do the same thing
-
Nick Krasnov over 11 yearsPeriod(
.
) terminates PL/SQL mode but does not run a PL/SQL block whereasrun
command or slash/
do. -
FloorDivision over 6 yearsAlso found that the
/
most definitely has to be on it's own line.