Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Dynamic SQL

Re: Dynamic SQL

From: Thomas Kyte <tkyte_at_oracle.com>
Date: 13 Oct 2002 18:10:59 -0700
Message-ID: <aod5j301tjp@drn.newsguy.com>


In article <aobc2h$lso$1_at_news-reader10.wanadoo.fr>, "arnaud says...
>
>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.

there is no such thing as "the values which follow them" in a database table.

Rows have no order unless you use an order by on the query and I see no possible way to "order by" with this data giving the following results:

>A C
>D C
>D E
>F NULL
>I used a curosr but how to make a dynamic update?
>

Scary -- you seem to assume that the data will come out in the order in which it is inserted -- which is 100% false.

You need a column in the table to give ORDER to the data, else the data comes out any which way it feels like it.

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

--
Thomas Kyte (tkyte@oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Sun Oct 13 2002 - 20:10:59 CDT

Original text of this message

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