| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: Dynamic SQL
This code will do the update for a single column (fix it to do whatever
column or columns you need);
UPDATE TAB1 X SET col1=( SELECT col1
   FROM TAB1
   WHERE ROWID=( SELECT ROWID
     FROM TAB1
     WHERE col1 IS NOT NULL
     AND ROWID>x.ROWID
     AND rownum=1
     ) )
"arnaud herve" <dillonais_at_wanadoo.fr> wrote in message
news:aobc2h$lso$1_at_news-reader10.wanadoo.fr...
> I've a table T like that
> X   Y
> -------
> A   NULL
> NULL C
> D    E
> F   NULL
>
> My Problem.
> I want to replace values equal to NULL by the value which follow them
> In my case, I'll get.
> A C
> D C
> D E
> F NULL
> I used a curosr but how to make a dynamic update?
>
> according to me,It would be like
> _____________________________________
> .........
> for i in 1..sql%rowcount-1 loop
> if X is null
> update T set X = select X from T
> where rownum = i+1;
> end loop;
> ..........
> _________________________________________
>
> it's  a sample of code, I know a dirty code, but simply to show you, what
I
> want to get.
>
>
>
Received on Mon Oct 14 2002 - 00:11:17 CDT
![]()  | 
![]()  |