Re: sql insert question/mlml

From: charles bankes <charliebankes_at_easynet.co.uk>
Date: 1997/05/02
Message-ID: <3369cfcc.13037538_at_news>#1/1


On 2 May 1997 06:07:35 GMT, ae299_at_FreeNet.Carleton.CA (Michel Lee) wrote:

>
>
>
>I will try to post this question since i am not sure where
>else to post. If this is the wrong newsgroup, then pls
>let me know.
>
>Question: I'd like to copy an existing row from a table
>into the same table, but with the primary key's value increased
>by 1. How can I do that without specifying all the fields in the
>statement (there are many fields in this table)?
>I cannot do
>
>insert into foo
> select * from foo where keyfield = 100
>
>since there is a unique key in 'foo'
>
>i am stumped, your help is apprecreated.
>
>mike
>--
> /-----------------------------------------------/ \--\--\ \-- \-- \--
> / www.ncf.carleton.ca/~ae299 /---\ \ \ \\ \ \
> / ae299_at_freenet.carleton.ca /-----\ \ \\-- \-- \--
> /-----------------------------------------------/

You could always you a before insert trigger on the table that would check if the primary key value already exists and if it does the change the :new value to equal :new value + 1

Charles Bankes
charliebankes_at_easynet.co.uk Received on Fri May 02 1997 - 00:00:00 CEST

Original text of this message