BdLm
asked on
extract "Create Tablle SQL" statement from a paradox table
I'm looking for a function like this
function ExtractCreateTabSQl ( aTable : TTable; var aSQLString : String);
{*
in
aTable : A Paradox Table
out
aSQLString : the string to create this table unsing the create table SQL
*}
begin
for I := 0 ...n
// loop through all field
// get Field Name
// get Field Type
// addd to SQL String
end;
end;
function ExtractCreateTabSQl ( aTable : TTable; var aSQLString : String);
{*
in
aTable : A Paradox Table
out
aSQLString : the string to create this table unsing the create table SQL
*}
begin
for I := 0 ...n
// loop through all field
// get Field Name
// get Field Type
// addd to SQL String
end;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
here is the complete code
ASKER
* in :
* aTable : A Paradox Table
* out :
* aSQLString : the string to create this table unsing the create table SQL
* used: ftdatatypeStrMSSQL, ftdatatypeStr a function to
* create the Datatype string
* BdLm
**************************
procedure ExtractCreateTabSQl ( aTable : TTable; var aSQLString : String);
var i : Integer;
aFieldName : String;
aFieldType : String;
aFieldSize : String;
tabName : String;
begin
tabName := ExtractFilename(aTable.Tab
aSQLString := '';
aSQLString := 'Create table ' + tabName ;
aSQLString := aSQLString + ' ( ';
for I := 0 to aTable.FieldCount -1 do
begin
// loop through all fields
// get Field Name
aFieldName := aTable.Fields[i].FieldName
// get Field Type
aFieldType := ftdatatypeStrMSSQL(aTable.
// aFieldType := ftdatatypeStr(aTable.Field
// Data size
aFieldSize := '(' + IntToStr( aTable.Fields[i].DataSize -1 ) +') NULL ';
if ((aFieldType = 'varchar') or (aFieldType = 'varbinary')) then
aFieldSize := ' NULL';
if ( (aFieldType = 'float') or (aFieldType = 'int') or (aFieldType = 'datetime') or (aFieldType = 'smallint') )then
aFieldSize := ' NULL';
// add to SQL String
aSQLString := aSQLString + aFieldName + ' ' + aFieldType + aFieldSize + ' ' ;
if i <> (aTable.FieldCount -1 ) then aSQLString := aSQLString + ', ';
end;
aSQLString := aSQLString + ') ';
end;