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: How can I copy rows into same table?

Re: How can I copy rows into same table?

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Tue, 10 Feb 2004 18:30:01 +0100
Message-ID: <402914b8$0$28633$626a14ce@news.free.fr>

"Andrew Strader" <astrader_at_ecnext.com> a écrit dans le message de news:4e0ac0a4.0402100900.4cd77bb7_at_posting.google.com...
> Here's a specific question that I have about Oracle SQL. I have a
> table that is aggregated by a column called "store_id". Each store_id
> has several rows associated with it. The store_id '999' represents the
> "template" store. Whenever I add a new store, I copy all the template
> rows out and then insert them back in with the new id. After copying
> the rows from the template, I customize them per the store owner's
> requests. (That's why I need to be able to do this.) Right now the way
> I do it is by using a program that performs a SELECT and pulls all the
> rows, changes the STORE_ID, then issues several INSERT queries to put
> the rows into the table for that new store. But I don't like having to
> transfer the data with an external program, because it is getting hard
> to maintain this solution and keep it portable. Is there a way to
> perform this operation with using only SQL? Just point me in the right
> direction. Thanks!

I'm not sure i understand your problem, but try something like:

insert into my_table (store_id, col1, col2, col3) (select <new_store_id>, col1, col2, col2 from my_table where store_id=999);

Regards
Michel Cadot Received on Tue Feb 10 2004 - 11:30:01 CST

Original text of this message

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