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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: dynamic insert querry

Re: dynamic insert querry

From: Bob Metelsky <bobmetelsky_at_comcast.net>
Date: Sat, 19 Mar 2005 13:55:47 -0500
Message-ID: <423C75B3.1080703@comcast.net>


Arul, Thank you very much, thats perfect! You saved me allot of time

Thanks again

Bob

"Oracle error messages being what they are, do not highlight the correct cause of fault, but will identify some other error located close to where the real fault lies."

Arul Ramachandran wrote:

>I am not sure if I have understood your problem ... see if this helps ...
>-------------------------------------------------------------------
>begin
>for rec in (select distinct batch_id from source)
>loop
> insert into target
> select * from src
> where batch_id = rec.batch_id
> and rownum < 1001;
>end loop;
>end;
>/
>-------------------------------------------------------------------
>
>-Arul
>
>On Sat, 19 Mar 2005 08:37:24 -0500, Bob Metelsky
><bobmetelsky_at_comcast.net> wrote:
>
>
>>All - I need to build an insert statement for the following condition
>>
>>I have a column with batch_ids with counts from 1-500k
>>I want to build an insert statement that will pull n# of rows
>>
>>So I want to insert 1000 rows of each batch id (dosnt matter which) I
>>just need a sampling of the data
>>
>>goal
>>insert into table
>>select * from source where batch_id = 123 and count(batch_id) between
>>max(count(batch_id) ) -1000 ;
>>
>>this is what I have so far, its messy and still needs work
>>
>>select 'insert into TARGET select * from SOURCE where batch_id =
>>'||batch_id|| '
>>and count(batch_id) BETWEEN' ,count(batch_id)|| ' AND 100;'
>>from SOURCE where rownum <=10 group by batch_id;
>>
>>There must be a more graceful way to do this <g>
>>
>>thanks !
>>Bob
>>
>>--
>>"Oracle error messages being what they are, do not
>>highlight the correct cause of fault, but will identify
>>some other error located close to where the real fault lies."
>>
>>--
>>http://www.freelists.org/webpage/oracle-l
>>
>>
>>
>
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Sat Mar 19 2005 - 13:59:19 CST

Original text of this message

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