Autor Beitrag
saxe66
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 104



BeitragVerfasst: Di 17.04.12 07:54 
Hallo Delphianer,

ich möchte ein Memo von einer Datenbank in eine andere kopieren. Wie kann man das ohne umständliches (sprich zeilenweises) Auslesen realisieren ?

Mein Ansatz war eigentlich folgender :

Variable m1 vom Typ TMemo,

Q1.SQL.Add('select fmemo from tabelle')
...

m1:=Q1.Fields[0].Value
...

Q2.SQL.Add('insert into neuetabelle (fmemo) values(m1)');

Funktioniert leider nicht, hat jemand eine Lösung ?

Danke ...
zuma
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 660
Erhaltene Danke: 21

Win XP, Win7, Win 8
D7 Enterprise, Delphi XE, Interbase (5 - XE)
BeitragVerfasst: Di 17.04.12 11:08 
user profile iconsaxe66 hat folgendes geschrieben Zum zitierten Posting springen:

Q1.SQL.Add('select fmemo from tabelle')
...

m1.Lines.Text := Q1.Fields[0].AsString;
...

Q2.SQL.Add('insert into neuetabelle (fmemo) values('m1.Lines.Text')');



Mal so aus dem Bauch, keine Garantie ;)

_________________
Ich habe nichts gegen Fremde. Aber diese Fremden sind nicht von hier! (Methusalix)
Warum sich Sorgen ums Leben machen? Keiner überlebts!
haentschman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 285
Erhaltene Danke: 33


DX10 Berlin Professional
BeitragVerfasst: Di 17.04.12 19:21 
Hallo...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
Q1.SQL.Add('select fmemo from tabelle')
...

m1.Lines.Text := Q1.Fields[0].AsString;
...

Q2.SQL.Add('insert into neuetabelle (fmemo) values('m1.Lines.Text')');

...die SQL Abfrage kann doch das Memo nicht kennen. Ein + dazwischen um den SQL String zusammenzusetzen hätte ich grad gelten lassen. Aber: Warum über eine visuelle Komponente als Umweg ? :gruebel:

Vorschlag ohne Umweg mit Parametern (wichtig und überhaupt :zwinker:) :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Q1.SQL.Text:= 'select fmemo from tabelle';
Q1.Open;

while not Q1.Eof do
begin
  Q2.SQL.Text:= 'insert into neuetabelle (fmemo) values (:B)';
  Q2.ParamByName('B').Value:= Q1.FieldByName('fmemo').Value;
  Q2.ExecSQL;
  Q1.Next;
end;
saxe66 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 104



BeitragVerfasst: Do 19.04.12 13:16 
Danke für eure Hilfe ...