Re: HELP....CURSORS

From: Scott Urman <surman_at_oracle.com>
Date: 1995/05/16
Message-ID: <3p8so8$7md_at_inet-nntp-gw-1.us.oracle.com>#1/1


In article <3p1g5d$hdk_at_wraith.cs.uow.edu.au>, ahsan_at_wraith.cs.uow.edu.au (Ahsan Jalil) writes:
|>
|> Iam having trouble in using cursors i.e how to define two cursors one after
|> the other in a PL/SQL procedure. What iam trying to do is
|>
|> create procedure temp(....) as
|>
|> cursor a is
|> select...
|> from....
|> where...
|> begin
|> for var in a
|> loop
|> (statements)
|> end loop
|>
|>
|> cursor b is
|> select...
|> from....
|> where...
|> begin
|> for var in b
|> loop
|> (statements)
|> end loop
|> end temp;
|>
|>
|> THE PROBLEM IS THAT IT'S NOT WORKING THIS WAY i.e I am not been able to
|> define more than one cursor in a procedure.
|> CAN WE DO IT IN THIS WAY OR IS THERE ANY OTHER WAY ?.
|>

Of course. You need to define both cursors in the declarative part of the block, before the begin:

procedure p(...) is
  cursor a is ...
  cursor b is ...

begin
  open a;
  for rec in b loop
   ...
end p;

|> The second problem is how to change the headings while u r in procedure.
|> i.e how to change
|>
|> EMP_NAME EMP-NO
|> ---------------------
|> JACK 123
|> MARK 456
|>
|> to
|>
|> Employer Name Employer No
|> ------------------------------
|> JACK 123
|> MARK 456
|>
|> REMEMBER WE R WORKING IN A PROCEDURE
|> Therefore the commands like SET HEADINGS OFF DOES NOT WORK..

Right - because these are SQL*Plus commands. You can't use a stored procedure to do this.

|>
|> Please reply
|> Thank you in advance
|> ahsan_at_wraith.cs.uow.edu.au
Received on Tue May 16 1995 - 00:00:00 CEST

Original text of this message