Page 1 of 1
How can I copy a record from one table to another
Posted: Thu 07 Apr 2005 12:36
by el_ade
I have a table where the users send reviews, this review is stored in a tempo table, when I aprove the review I need to copy the record data in table1 (tempo) to table2.
I´m doing this with delphi, I have tryed to use the TmyScript component but I can´t make the recovering of the fields content.
¿Can somebody help me?
Posted: Thu 07 Apr 2005 13:10
by Ikar
It would be correct to perform this task at the server using INSERT ... SELECT statement
Posted: Thu 07 Apr 2005 13:23
by Guest
I´m trying to use the following code, and I supose it will work, but I wonder if ther isn´t an easyer way to do the same.
MyCommand1.SQL.Text := 'insert into reviews values (NULL,'''+
QReviews_Add.Fieldbyname('date').AsString +''','''+
QReviews_Add.FieldByName('title').AsString +''','''+
QReviews_Add.FieldByName('text').AsString +''','''+
QReviews_Add.FieldByName('reviewer').AsString +''','''+
QReviews_Add.FieldByName('email').AsString +''','''+
QReviews_Add.FieldByName('score').AsString +''','''+
'1'','''+
QReviews_Add.FieldByName('url').AsString +''','''+
'1'','''+
QReviews_Add.FieldByName('rlanguage').AsString+
''')';
Memo1.Text := MyCommand1.SQL.Text;
MyCommand1.Execute;
Posted: Fri 08 Apr 2005 07:24
by Ikar
After that as QReviews.Post was executed you should execute the next:
MyCommand1.SQL.Text := 'insert into reviews (date, title, text, reviewer, email, score, url, rlanguage, ...)SELECT date, title, text, reviewer, email, score, url, rlanguage, 1, 1 FROM qreviews';
MyCommand1.Execute;