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:=Table2FIELD.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
LVL 1
rpetruniAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

elkiorsCommented:
TBatchMove standalone component allows you to specify the field link definitions under the Mappings property and is much more powerful than tTable.Batchmove.
0
kretzschmarCommented:
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 ;-)
0
simonetCommented:
>(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
0
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

elkiorsCommented:
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
0
rpetruniAuthor Commented:
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
0
kretzschmarCommented:
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(query1.RowsAffected)+' Records are inserted');
  except
    showmessage('There was an error');
  end;
end;

one remark, source- and destinationfields should have the same datatyp

meikl ;-)
0
rpetruniAuthor Commented:
Ok Kretzschmar,

Answer this and i'l give you 150 pts,

Elkiors where are you?
Robert
0
kretzschmarCommented:
well robert,

glad to helped you
good luck again

meikl ;-)

hi darren,
just remembered,
will make it ready,
if i've idle time
meikl

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rpetruniAuthor Commented:
Elkiors, do you want your points or not?
0
elkiorsCommented:
Yes Please, sorry I've not been checking my mail as often as I should

Glad you got more than one solution

Darren
0
elkiorsCommented:
I thought that under the new E-E design you could allow a comment as an accepted answer.

Darren
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.