Re: COPY FROM - how to identify results?
От | Jaime Silvela |
---|---|
Тема | Re: COPY FROM - how to identify results? |
Дата | |
Msg-id | 46139D80.1010202@bear.com обсуждение исходный текст |
Ответ на | Re: COPY FROM - how to identify results? (Klint Gore <kg@kgb.une.edu.au>) |
Список | pgsql-general |
I can't use triggers because I need a specific "my_id". Here's the scenario: a user is browsing the web page for portfolio_id = 3, and wants to update the values. He uploads a CSV file, and I need its entries to be tagged with portfolio_id = 3, as another user could be uploading a CSV file for portfolio_id = 9. As suggested by John Burger, I think the cleanest way to deal with this is to have the CSV file COPY'd to a TEMP table, local to the user's session, and from there inserted with INSERT INTO portfolio(field-1, .. field-n, portfolio_id) SELECT field-1, .. field-n, 3 FROM ....; Thank you, Jaime Klint Gore wrote: > On Tue, 03 Apr 2007 12:45:54 -0400, Jaime Silvela <JSilvela@Bear.com> wrote: > >> I'd like to be able to do something like >> COPY mytable (field-1, .. field-n, id = my_id) FROM file; >> > > How do you get my_id? Can you get it in a trigger? Triggers still fire > with copy so if you can get a trigger to fill in the id column you can > copy with just the field names. > > klint. > > +---------------------------------------+-----------------+ > : Klint Gore : "Non rhyming : > : EMail : kg@kgb.une.edu.au : slang - the : > : Snail : A.B.R.I. : possibilities : > : Mail University of New England : are useless" : > : Armidale NSW 2351 Australia : L.J.J. : > : Fax : +61 2 6772 5376 : : > +---------------------------------------+-----------------+ > > *********************************************************************** Bear Stearns is not responsible for any recommendation, solicitation, offer or agreement or any information about any transaction, customer account or account activity contained in this communication. Bear Stearns does not provide tax, legal or accounting advice. You should consult your own tax, legal and accounting advisors before engaging in any transaction. In order for Bear Stearns to comply with Internal Revenue Service Circular 230 (if applicable), you are notified that any discussion of U.S. federal tax issues contained or referred to herein is not intended or written to be used, and cannot be used, for the purpose of: (A) avoiding penalties that may be imposed under the Internal Revenue Code; nor (B) promoting, marketing or recommending to another party any transaction or matter addressed herein. ***********************************************************************
В списке pgsql-general по дате отправления: