Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Create a new table from old EDBTable with calc fields
Wed, Jul 7 2010 5:25 AMPermanent Link

Mauro Botta

Hi

I have a EDBTable with any calc fields and any LookupFields.

i need to generate a new table ( memory ... or real.. )  where the
"calcfield " field are transformed in true data field.

example :

TRUE_DATA_FIELD_1 INTEGER
MyCalcFieldForDescritionExtraTable STRING 30
...

to :

TRUE_DATA_FIELD_1 INTEGER
TRUE_DATA_FIELD_2 STRING 30
...

Any hint ?
Wed, Jul 7 2010 5:46 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Mauro


What about CREATE TABLE AS ... WITH DATA

Roy Lambert [Team Elevate]
Wed, Jul 7 2010 6:06 AMPermanent Link

Mauro Botta

>>> What about CREATE TABLE AS ... WITH DATA

Hi Roy

i don't understand.


How i can use CREATE TABLE and get Field Structure from my EDBTable with CalcFields ?
Wed, Jul 7 2010 6:36 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Mauro


Where are the calcfields defined - within ElevateDB or as part of a table in Delphi?

Roy Lambert [Team Elevate]
Wed, Jul 7 2010 6:57 AMPermanent Link

Mauro Botta

>Where are the calcfields defined - within ElevateDB or as part of a table in Delphi?

part of a table in Delphi
Wed, Jul 7 2010 8:20 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Mauro


In that case, and hoping all the fields you need are defined in the Delphi table, check out my post in the extensions ng


Post: 1460696B-1D30-4A8C-992B-407699554EC0@news.elevatesoft.com
Subject: Generate in memory table from TEDBTable component on a form

I use it to generate in-memory tables from the table field & index definitions, but it would be trivial to point at a disk instead. You'll need to change this:

 if WhichTable.FieldList[Cntr].FieldKind = fkData

to allow calculated fields as well.

That will get you the structure. Populating the table would then be a simple Delphi procedure - loop through the source and insert into the copy.

Roy Lambert [Team Elevate]
Wed, Jul 7 2010 9:26 AMPermanent Link

Mauro Botta

Good source Smile




only question :

----

for Cntr := 0 to WhichTable.FieldList.Count - 1 do begin
   if WhichTable.FieldList[Cntr].FieldKind = fkData then
      Maker.SQL.Add('"' + WhichTable.FieldList[Cntr].FieldName + '" ' + GetFieldType(WhichTable.FieldList[Cntr])  ',');
end;

----

-> if WhichTable.FieldList[Cntr].FieldKind = fkData then

Can i remove this code for create TRUE FIELDS for "CalcField"   fields ?
Wed, Jul 7 2010 10:25 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Mauro


Best way to find out is to try it Smiley

I think fkCalculated dields hold the necessary information.

From the D2006 OLH

TFieldKind = (fkData, fkCalculated, fkLookup, fkInternalCalc, fkAggregate);

So I'd probably alter the test to   if WhichTable.FieldList[Cntr].FieldKind in (fkData, fkCalculated) then ... rather than remove it. I have no idea what creates these two types fkInternalCalc, fkAggregate so I'd play safe.

Roy Lambert [Team Elevate]
Image