![]() |
Re: SQL Kommando und ADO
Hallo,
alzaimar: zu deinen Bemerkungen gebe ich hier keinen Kommentar. ich hatte ganz klar beschrieben was ich machen wollte, nämlich eine Tabelle kopieren, sonst nichts. Lösung: select * into Tabelle2 from Tabelle1 Wenn mir noch jemand sagt wie man das ohne Inhalte macht bin ich zufrieden. Danke |
Re: SQL Kommando und ADO
Zitat:
Zitat:
Zitat:
|
Re: SQL Kommando und ADO
Zitat:
Zitat:
Du hast übrigens *nicht* ganz klar beschrieben, was Du machen wollstest: Du hast von 'COPY' Befehlen gefalselt, aber nicht, WOHIN eine Tabelle kopiert werden soll. Du bist auch nicht auf die Fragen der anderen Teilnehmer eingegangen. |
Re: SQL Kommando und ADO
Ich hatte in #1 schon gefragt wie du das meinst, diese Frage hast du deinerseits ja nie beantwortet.
Du willst also eine neue Tabelle mit der selben Struktur einer anderen anlegen |
Re: SQL Kommando und ADO
Zitat:
Das war leider nicht so klar, wie du meinst. Eine Tabelle hast du hier nämlich nicht kopiert, sondern Daten von Tab A nach Tab B geschoben. Ein Kopieren impliziert die Neuanlage der Tabelle(nstruktur), und da hat alzaimar dann recht, da müsste man dann erst ein Kommando zum Erstellen aufbauen. Hier ein bisserl Code für den Aufbau (evtl. DB2-spezifisch und durchaus noch zu verbessern):
Delphi-Quellcode:
Cu,
procedure GenerateDDLOfDataset(Dataset: TDataset; DDL: TStrings; Options: TGenerateOptions);
var i: integer; var Str: string; var Field: TField; begin //Create-Befehl DDL.Clear; DDL.Add('CREATE TABLE "SCHEMA"."TABELLE"'); DDL.Add('('); //Alle Felder auflisten for i := 0 to Dataset.Fields.Count - 1 do begin //Feldnamen Field := Dataset.Fields[i]; //nicht sichtbare Felder ignorieren? if not Field.Visible and (goIgnoreUnvisibleFields in Options) then Continue; Str := '"' + Uppercase(Field.FieldName) + '"'; //Feldtyp if Field is TIntegerField then Str := Str + ' integer' else if Field is TFloatField then Str := Str + ' double' else if Field is TStringField then Str := Str + ' varchar(' + IntToStr(TStringfield(Field).Size) + ')' else if Field is TDateField then Str := Str + ' date' else if Field is TTimeField then Str := Str + ' time' else if Field is TDateTimeField then Str := Str + ' timestamp' else if Field is TSQLTimeStampField then Str := Str + ' timestamp' else if Field is TMemoField then Str := Str + ' clob(???) logged' else if Field is TBlobField then Str := Str + ' blob(???) logged' else raise Exception.CreateFmt('Feldtyp für Klasse %s unbekannt.', [Field.ClassName]); //nicht null? if Field.Required then Str := Str + ' not null'; //Letztes Feld? Kein Komma if i < Dataset.Fields.Count - 1 then Str := Str + ','; DDL.Add(Str); end; DDL.Add(')'); DDL.Add('IN "USERSPACE1";'); end; Udontknow |
Re: SQL Kommando und ADO
Hallo,
es funktioniert genauso wie ich oben beschrieben hatte. select * into Tabelle2 from Tabelle die Tabelle wird angelegt und der Inhalt mitkopiert. Danke |
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:00 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz