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: Newbie Cursor Question

Re: Newbie Cursor Question

From: DA Morgan <damorgan_at_psoug.org>
Date: Mon, 06 Jun 2005 23:24:16 -0700
Message-ID: <1118125468.991795@yasure>


Keith wrote:
> What's wrong with this code? I want to be able to replace instances of the
> ampersand character with the string "AND" but this code seems to go into an
> end less loop and updates nothing. The query in the cursor works on its own
> so there must be something I'm missing with the loop.
>
> Many thanks,
> Keith.
>
> declare
>
> cursor c1 is
> select replace(ver_drg_title,chr(38),'AND')
> from oms_version_tbl
> where instr(ver_drg_title,'&',1,1)>0
> for update of ver_drg_title;
>
> v_title oms_version_tbl.ver_drg_title%type;
>
> begin
>
> open c1;
> loop
> fetch c1 into v_title;
> exit when c1%notfound;
> update oms_version_tbl
> set ver_drg_title = v_title
> where current of c1;
> end loop;
> close c1;
>
> end;

Rauf's answer is correct.

But even if you did need to use a looping structure ... the cursor loop you wrote is the worst possible solution unless in Oracle version 8i or earlier.

http://www.psoug.org
click on Morgan's Library
click on Bulk Binding

-- 
Daniel A. Morgan
http://www.psoug.org
damorgan_at_x.washington.edu
(replace x with u to respond)
Received on Tue Jun 07 2005 - 01:24:16 CDT

Original text of this message

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