rpetruni
asked on
Appending from one table to other
Hi all,
How to append from one table to other (tables are not the same, they have some fields same, but the order is not the same), without this kind of code:
Table1FIELD.Value:=Table2F IELD.Value ;
It has to be possible (Batch move DOES NOT do the Yob)...
TableSource have all fields from TableDestination, but tabledestination is bigger and fields have different order.
Robert
How to append from one table to other (tables are not the same, they have some fields same, but the order is not the same), without this kind of code:
Table1FIELD.Value:=Table2F
It has to be possible (Batch move DOES NOT do the Yob)...
TableSource have all fields from TableDestination, but tabledestination is bigger and fields have different order.
Robert
TBatchMove standalone component allows you to specify the field link definitions under the Mappings property and is much more powerful than tTable.Batchmove.
hi robert,
you can do it with a sql-statement like
insert into DestTable
(DestField1,
DestFirld2)
select
SourceField1,
SourceField2
from SourceTable
hi darran,
if i remember right,
then you wanted something from me
what was it?
excuse me, i've forgotten it
meikl ;-)
you can do it with a sql-statement like
insert into DestTable
(DestField1,
DestFirld2)
select
SourceField1,
SourceField2
from SourceTable
hi darran,
if i remember right,
then you wanted something from me
what was it?
excuse me, i've forgotten it
meikl ;-)
>(Batch move DOES NOT do the Yob)...
YEs, it does the job. As elkiors suggested, just set the MAPPINGS property correctly are you'll be on the right track.
Alex
YEs, it does the job. As elkiors suggested, just set the MAPPINGS property correctly are you'll be on the right track.
Alex
Meikl:
Not to worry, I was after you helping me with some create table + validation problems, it's not critical so think no more about it.
Darren
Not to worry, I was after you helping me with some create table + validation problems, it's not critical so think no more about it.
Darren
ASKER
Elkiors,
please answer the q so i could give you your pints...
KretzSchmar,
if you give me some simple (working) example of your suggestion (with query)i will give you 100+ points...
Robert
please answer the q so i could give you your pints...
KretzSchmar,
if you give me some simple (working) example of your suggestion (with query)i will give you 100+ points...
Robert
well robert,
lets say we have two tables,
tableName_Source contains the fields
a,b,c
tableName_Dest contains the fields
d,e,f,g,h
and we want to append records by insterting the fields a,c into the fields e,h
the sql-statement is then
insert into table_Dest (e,h) select a,c from table_Source
in code
procedure TForm1.Button1Click(Sender : TObject);
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('insert into table_Dest (e,h) select a,c from table_Source');
try
query1.ExecSQL;
showmessage(inttoStr(query 1.RowsAffe cted)+' Records are inserted');
except
showmessage('There was an error');
end;
end;
one remark, source- and destinationfields should have the same datatyp
meikl ;-)
lets say we have two tables,
tableName_Source contains the fields
a,b,c
tableName_Dest contains the fields
d,e,f,g,h
and we want to append records by insterting the fields a,c into the fields e,h
the sql-statement is then
insert into table_Dest (e,h) select a,c from table_Source
in code
procedure TForm1.Button1Click(Sender
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('insert into table_Dest (e,h) select a,c from table_Source');
try
query1.ExecSQL;
showmessage(inttoStr(query
except
showmessage('There was an error');
end;
end;
one remark, source- and destinationfields should have the same datatyp
meikl ;-)
ASKER
Ok Kretzschmar,
Answer this and i'l give you 150 pts,
Elkiors where are you?
Robert
Answer this and i'l give you 150 pts,
Elkiors where are you?
Robert
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Elkiors, do you want your points or not?
Yes Please, sorry I've not been checking my mail as often as I should
Glad you got more than one solution
Darren
Glad you got more than one solution
Darren
I thought that under the new E-E design you could allow a comment as an accepted answer.
Darren
Darren