Re: Dynamic SQL

From: M Hashim <m.a.n.hashim_at_sympatico.ca>
Date: Sun, 13 Oct 2002 22:11:17 -0700
Message-ID: <pGpq9.1090$Lb1.143860_at_news20.bellglobal.com>


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
     ) )

WHERE col1 IS NULL;

"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 - 07:11:17 CEST

Original text of this message