Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Newbie Cursor Question
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;
Why not just use,
update oms_version_tbl
set ver_drg_title = replace(ver_drg_title, chr(38), 'AND') where instr(ver_drg_title, chr(38), 1, 1) > 0;
Regards
/Rauf
Received on Mon Jun 06 2005 - 06:44:38 CDT