Autor Beitrag
Nightfly
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 163



BeitragVerfasst: Mi 22.10.03 10:28 
Hallo

ich möchte die komplette Tabelle 1 in die Tabelle 2 kopieren. Beide Tabellen existieren und sind von den felddefinitionen her logischerweise identisch.

Also praktisch so:
ausblenden Quelltext
1:
2:
3:
 while Table1.FindNext do begin {Datensatz in table 2 schreiben} end;

bloß wie mach ich das Datensatz in TAble 2 schreiben?
Maggi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 160

WIN XP, WIN 2003
D5 Enter D 2006
BeitragVerfasst: Mi 22.10.03 10:38 
Hi,

hmm verstehe dein Problem nicht so ganz glaube ich, aber ich versuche es trotzdem mal:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
tabelle1.First

while not tabelle1.eof do
begin
   tabelle2.edit;
   tabelle2.feld01 := tabelle1.feld01;
   tabelle2.feld02 := tabelle1.feld02;
   tabelle2.feld03 := tabelle1.feld03;
   .
   .

   tabelle2.post;

   tabelle1.next;
end;

Hoffe das hilft dir ein wenig

Gruß
maggi

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.
Maggi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 160

WIN XP, WIN 2003
D5 Enter D 2006
BeitragVerfasst: Mi 22.10.03 10:39 
Hi nochmal,

das muß natürlich nicht tabelle1.edit heißen sondern

tabelle1.insert!!!!!!

Gruß

maggi
joerg68
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 116

Win 2000
D5Enterprise
BeitragVerfasst: Mi 22.10.03 10:41 
@ Maggi
Tabelle2.edit ist nicht korrekt.
Tabelle2.append ist richtig

Mit Deiner Version würdest Du den selben Datensatz immer wieder neu überschreiben und zum Schluß würde nur der letzte Datensatz der Tabelle1 in der Tabelle2 stehen.

Gruß
Jörg

_________________
Aus den Chaos sprach eine Stimme " Lächele und sei froh denn es könnte schlimmer kommen". Und ich lächelte und ich war froh.
UND ES KAM SCHLIMMER
Maggi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 160

WIN XP, WIN 2003
D5 Enter D 2006
BeitragVerfasst: Mi 22.10.03 10:49 
Hallo,

@Jörg68

Sehr richtig erkannt, deswegen habe ich ja auch einen zweiten Eintrag hinterhergeschickt indem ich mich verbessert habe.....

Ich hoffe tab.Insert gefällt dir auch!?!? :wink:

Gruß

Maggi
Myocard
Hält's aus hier
Beiträge: 2


D7 Architect
BeitragVerfasst: Mi 22.10.03 10:52 
Einfach mit einem SQL-Befehl:
ausblenden Quelltext
1:
2:
INSERT INTO Tabelle2 (Spalte1, Spalte2, ...)
  SELECT Spalte1, SPalte2, ... FROM Tabelle1


Gruß
Myo
Nightfly Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 163



BeitragVerfasst: Mi 22.10.03 10:52 
Ja, so ähnlich hab ich mir das Gedacht.

ich hab jetzt folgendes:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
while Table2.FindNext do
begin
  for loop := 0 to 17 do 
  begin
    Table3.Append; 
    Table3.Fields[loop].asInteger := Table2.Fields[loop].asInteger; 
    Table3.Post;
  end;
end;

So, das würde auch gehen, WENN alle meine Felder Integer wären, aber die sind von 0 bis 17 gemischt, und zwar Integer,Strings und Logical.
Gibt es statt .asInteger etwas wie .asAlswasesinderTabellesteht ? :wink:

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
Maggi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 160

WIN XP, WIN 2003
D5 Enter D 2006
BeitragVerfasst: Mi 22.10.03 10:59 
Hi nochmal,

wie wäre es denn wenn du einfach CopyTable machst und die dannach neu indizierst. Dann solltest du auch den selben Effekt haben und brauchst nur einen Zweizeiler proggen?!?! :?:

gruß

Maggi
Nightfly Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 163



BeitragVerfasst: Mi 22.10.03 11:14 
a) Sorry, bin noch neu und weiß nich was copy table is..in der hilfe hab ich nix zu gefunden.
b) neu indizieren? Warum? und wie? in meiner (leeren) Zieltabelle hab ich zwei felder als Index, is das nich ausreichend?

Aber ob's wie oben von mir gefragt nen ersatz für asInteger gibt tät mich doch mal interessieren.
Nightfly Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 163



BeitragVerfasst: Mi 22.10.03 13:24 
da oben der Code war kompletter Mist

aber der nun folgende liefert schon ein ganz passables ergebniss, aber er vergisst einige datensätze :( warum bloß?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
begin
Table3.FindFirst;
Table3.Edit;
while Table3.FindNext do Table3.Delete;
Table2.Filtered := False;
Table2.FindFirst;
while Table2.FindNext do
begin
  Table3.Append;
  for loop := 0 to 17 do begin
    Table3.Fields[loop].Value := Table2.Fields[loop].Value;
  end;
  Table3.Post;
end;
Table2.Filtered := true;
Table3.Filter := Table2.Filter;
Table3.Filtered := true;
end;

Kann mir da bitte nochal jemand helfen?

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
barfuesser
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 324



BeitragVerfasst: Mi 22.10.03 15:22 
Welche Datensätze fehlen denn? Zufälligerweise der 1.?

barfuesser
Nightfly Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 163



BeitragVerfasst: Mi 22.10.03 17:29 
ähem..das hab ich noch gemerkt, und hab ne Fußgesteuerte schleife draus gemacht.

Aber es fehlt fast ein drittel, und zwar alle bei denen Table2.Fields[2].Value den wert 0 hat ..und bei allen andern ist nach dem rüberkopieren in besagtem Feld eine 01, obwohl in der quelle DEFINITIV auch Datensetzt mit dem wert 02 in diesem String Feld vorkommen :(

SEHR komisch...also für mich sieht diese schleife doch richtig aus :(