How to make an insert in mysql with data coming from a Simpledataset

Asked

Viewed 75 times

1

I have a Simpledataset with data from a Firebird local.

I have to make one Insert in the Mysql.

How should I do it?

Other Sqlconnect and another Simpledataset?

How to do the Insert with data from that other Simpledataset(Firebird).

1 answer

2


I don’t know how this component works, but overall you make a loop in the DataSet making insert of every one of his items!

It works like an importer!

Ex:

NomeDataSet.First
while not NomeDataSet.Eof do
begin
  //aqui seu Código SQL para efetuar o Insert
  NomeDataSet.Next
end;

And yes, you’ll need the two connections!

There where commented you perform the query who had effected the insert in the 2nd Sqlconnect (Mysql connection).

  • But the Insert I put in sql command. I would like to pass the data from one to the other. How can I do this?

  • I made an edit while your comment was inserted, take a look!

  • Something like that? 'insert interditado values ( (SELECT u.id as id_usuario FROM serventia s, usuarios u
 where u.serventia_id = s.id) as USUARIO_ID , SimpleDataSetNOME_PAI , SimpleDataSetMAE,
 sysdate(), SimpleDataSetCPFCNPJ );'

  • Exactly, the command is up to you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.