Subject | Re: [firebird-support] Re: Copying data from one table to another |
---|---|
Author | Helen Borrie |
Post date | 2008-10-14T00:27:04Z |
At 08:54 14/10/2008, you wrote:
ClientInfo:Client_ID PhoneNumber --> PersonInfo:Client_ID,
PersonType=0, PhoneNumber
update PersonInfo pi
set pi.PhoneNumber =
(select ci.PhoneNumber from ClientInfo ci
where ci.Client_ID = pi.Client_ID)
where pi.PersonType = 0
and exists (select 1 from ClientInfo ci1
where ci1.Client_ID = pi.Client_ID)
Note: you won't need the existence check if your PersonType = 0 criterion is actually the way you have recorded the fact that a corresponding ClientInfo record exists.
./heLen
>> Insert into PersonInfo (Client_ID, PersonType, PhoneNumber) selectNot essential. You can do this with a DSQL statement and a couple of correlated subqueries:
>> Client_ID, 0, PhoneNumber from ClientInfo
>
>
>Thanks Alexandre--but I need to clarify.
>
>The record in the destination table will already--I just need to move
>the data to the existing record.
>
>I'm thinking I need a stored proc. Right?
ClientInfo:Client_ID PhoneNumber --> PersonInfo:Client_ID,
PersonType=0, PhoneNumber
update PersonInfo pi
set pi.PhoneNumber =
(select ci.PhoneNumber from ClientInfo ci
where ci.Client_ID = pi.Client_ID)
where pi.PersonType = 0
and exists (select 1 from ClientInfo ci1
where ci1.Client_ID = pi.Client_ID)
Note: you won't need the existence check if your PersonType = 0 criterion is actually the way you have recorded the fact that a corresponding ClientInfo record exists.
./heLen