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: Help with procedure syntax

Re: Help with procedure syntax

From: Daniel Clamage <dclamageNOSPAM_at_telerama.com>
Date: Tue, 21 Sep 1999 23:26:39 -0400
Message-ID: <rugj3apjlg794@corp.supernews.com>


It should work, as far as I can tell. What error message do you get? Also, you should do the EXIT WHEN mycursor%NOTFOUND before the insert. What if the fetch returns no row?

--
- Dan Clamage
http://www.telerama.com/~dclamage
If you haven't crashed the Server,
you haven't been trying hard enough.
<cpereyra_at_ix.netcom.com> wrote in message news:7s93fh$4tn$1_at_nnrp1.deja.com...
> Hi:
>
> I am trying to learn the subtleties of programming the Oracle back
> end. My background is Sybase and MS SQL Server so some of the
> constructs in Oracle seem strange and the books I have don't offer
> enough lucid help. Well, here it goes:
>
> This works:
>
> create or replace procedure InsertName(namein in varchar2)
> as
> cursor mycursor is select lastname from res_hold where firstname =
> namein;
> myvar varchar2(30);
> begin
> open mycursor;
> loop
> fetch mycursor into myvar;
> insert into names (name) values (myvar);
> exit when mycursor%NOTFOUND;
> end loop;
> end;
>
> This, replacing the myvar varchar2(30) with myvar mycursor%ROWTYPE does
> not.
>
> create or replace procedure InsertName(namein in varchar2)
> as
> cursor mycursor is select lastname from res_hold where firstname =
> namein;
> myvar mycursor%ROWTYPE;
> begin
> open mycursor;
> loop
> fetch mycursor into myvar;
> insert into names (name) values (myvar);
> exit when mycursor%NOTFOUND;
> end loop;
> end;
>
> The question is why?
>
> Thanks in advance,
>
> Carlos.
>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Received on Tue Sep 21 1999 - 22:26:39 CDT

Original text of this message

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