Re: Where do SQL/PL programs execute from ?

From: FaheemRao <faheemrao_at_yahoo.com>
Date: 19 Dec 2003 23:49:14 -0800
Message-ID: <43b58913.0312192349.27749fe2_at_posting.google.com>


One way to execute it to make it a stored procedure at the end of code and another end;
like this
creat or replace procedure Test is

cursor bc is select * from bank;
> cursor brc (bn bank.b#%type) is select t#, city from branch where bn =
> branch.b#;
> cursor cc (cbn bank.b#%type, ctn branch.t#%type) is
> select distinct customer.c#, customer.name, customer.status,
> customer.city, account.balance from customer, account
> where account.c# = customer.c# and account.b# = cbn and account.t# =
> ctn;
> begin
> dbms_output.put_line
> ('+==============================================+');
> dbms_output.put_line('| Bank# Name City
> |');
> dbms_output.put_line

 cursor bc is select * from bank;
> cursor brc (bn bank.b#%type) is select t#, city from branch where bn =
> branch.b#;
> cursor cc (cbn bank.b#%type, ctn branch.t#%type) is
> select distinct customer.c#, customer.name, customer.status,
> customer.city, account.balance from customer, account
> where account.c# = customer.c# and account.b# = cbn and account.t# =
> ctn;
> begin
> dbms_output.put_line
> ('+==============================================+');
> dbms_output.put_line('| Bank# Name City
> |');
> dbms_output.put_line

and remove the declare keyword

like this

create or replace procedure Test is

GUEST <a_at_b.com> wrote in message news:<MPG.1a4d711a3427d3ca9896ce_at_nntp.slnt.phub.net.cable.rogers.com>...
> On Mon, 15 Dec 2003 22:14:42 GMT a_at_b.com says...
> > Hi all.
> >
> > I'm a newbie to ORacle and am planning to take a course in Oracle this
> > January. Can anyone tell me where a SQL/PL script is run from ? I tried
> > to run a simple SQL/PL script under SQL Plus but it doesn't work. Maybe
> > I was doing something wrong.
> >
> > Any suggestions would be greatly appreciated...
> >
> > Thanks in advance
> >
> > Victor
> >
>
> Ok here it is. If you need for me to post the SQL code which created the
> tables and populated I will.
>
> declare
>
> ('------------------------------------------------');
> for btuple in bc loop
> dbms_output.put_line('| '||btuple.b#||' '||btuple.name||'
> '||btuple.city||' ');
> dbms_output.put_line('| +==========================================+
> |');

 dbms_output.put_line('| | Branch#   City                           | 

> |');
 dbms_output.put_line('| -------------------------------------------- 

> |');
> for brtuple in brc(btuple.b#) loop
> dbms_output.put_line('| | '||brtuple.t#||' '||brtuple.city||'
> ');
> dbms_output.put_line('| | +======================================+ |
> |');
 dbms_output.put_line('| | |Customer# Name Status City Balance | |
> |');
 dbms_output.put_line('| | ---------------------------------------- | 

> |');
> for ctuple in cc(btuple.b#, brtuple.t#) loop
> dbms_output.put_line('| | | '||ctuple.c#||' '||ctuple.name||'
> '||ctuple.status||' '||ctuple.city||'
> '||ctuple.balance||' ');
> end loop;
> dbms_output.put_line('| | ---------------------------------------| |
> |');
 dbms_output.put_line('| -------------------------------------------- 

> |');
> end loop;
> dbms_output.put_line
> ('------------------------------------------------');
> end loop;
> dbms_output.put_line
> ('+==============================================+');
> end;
Received on Sat Dec 20 2003 - 08:49:14 CET

Original text of this message