Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: cursor problem.

Re: cursor problem.

From: Claire Darbaud <Claire.Darbaud_at_hec.ca>
Date: 1997/03/14
Message-ID: <332988EE.6243@hec.ca>#1/1

Vegard Tollefsen wrote:

  Chrysalis wrote:

> Vegard Tollefsen wrote:
> >
> > When I call the procedure 'show' I also want to send in an
> > argument 'grom'.
> > I want to use that argument when I define a cursor. Like this:
> >
> > create or replace procedure show (grom in varchar2) is
> > cursor rad is select * from Rom
> > where Type=grom
> > and Stoerrelse>=6
> > and Stoerrelse<=15;
> > r rad%rowtype;
> > begin
> > open rad;
> > fetch rad into r;
> > htp.print
> >

 (r.Romnummer||r.Stoerrelse||r.Blokk||r.Etasje||r.Type||r.Status);
> > end
> > /
> >
> > But this dont work the way it should. Why??
> > Thanks.
> >
> So what way *does* it work? Or doesn't it work at all?
> What is the problem?
>
> Chrysalis.
>

  The select expresion dont use "grom" as it should. It seems it dont   use
  the argument at all. The procedure dont write out anything.   I dont get any errors.
  If I replace "grom" whith a real variable, like:

  create or replace procedure show (grom in varchar2) is   cursor rad is select * from Rom

                   where Type='Grupperom'
                   and Stoerrelse>=6
                   and Stoerrelse<=15;

  It all works fine. But I want to use "grom".   Help is needed!
  Thanks.

When you want to pass parameters to a cursor, you have to declare them in the cursor:

create or replace procedure show (grom in varchar2) is cursor rad (grom IN VARCHAR2)is

              select * from Rom
               where Type=grom
               and Stoerrelse>=6
               and Stoerrelse<=15;

rad%rowtype;
begin
open rad(grom);
fetch rad into r;
htp.print
(r.Romnummer||r.Stoerrelse||r.Blokk||r.Etasje||r.Type||r.Status); end
/
--
 _________________________________________________________________

 __________________          _-_
 \________________|)____.---'---`---.____    Claire Darbaud
              ||    \----._________.----/    Claire.Darbaud_at_hec.ca
              ||     / ,'   `---'
           ___||_,--'  -._                   Ecole des HEC
          /___          ||(-                 Montreal, Qc, CANADA
              `---._____-'
Received on Fri Mar 14 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US