Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 10 of 10 total |
OnCalc and Memory tables |
Thu, Jan 10 2008 9:38 PM | Permanent Link |
Pat | Hi,
I have a disk table (with 2 calculated fields) and I want the equivalent in a memory table. What I have coded so far gives me all the fields except the Calculated ones. I searched the newsgroup, but still cannot get it working. So far I have with memOrderGridTemp1 do begin with FieldDefs do begin Clear; Add('OrderGridID',ftAutoInc,0,False); Add('OrderID',ftInteger,0,False); Add('Description',ftMemo,0,False); Add('Description2',ftString,80,False); Add('Qty',ftFloat,0,False); Add('Rate',ftCurrency,0,False); end; with IndexDefs do begin Clear; Add('','OrderGridID',[ixPrimary,ixUnique]); Add('Owner','OrderID',[]); end; if not Exists then CreateTable; end; memOrderGridTemp1.Append; memOrderGridTemp1OrderID.Value:=1; memOrderGridTemp1Description.AsVariant:='line 1'+#13+''+#10+'line 2'+#13+''+#10+'line 3'; memOrderGridTemp1Qty.Value:=2; memOrderGridTemp1Rate.Value:=12.5; memOrderGridTemp1.Post; I would like calculated fields Amount and Tax Amount = Qty * Rate Tax 0.1 * Amount Thanks, Pat |
Fri, Jan 11 2008 2:13 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Pat,
<< I have a disk table (with 2 calculated fields) and I want the equivalent in a memory table. What I have coded so far gives me all the fields except the Calculated ones. I searched the newsgroup, but still cannot get it working. >> See here: http://www.elevatesoft.com/scripts/newsgrp.dll?action=openmsg&group=5&msg=59237&page=1#msg59237 -- Tim Young Elevate Software www.elevatesoft.com |
Fri, Jan 11 2008 3:15 PM | Permanent Link |
Pat | Tim,
><< I have a disk table (with 2 calculated fields) and I want the equivalent >in a memory table. What I have coded so far gives me all the fields except >the Calculated ones. I searched the newsgroup, but still cannot get it >working. >> > >See here: > >http://www.elevatesoft.com/scripts/newsgrp.dll?action=openmsg&group=5&msg=59237&page=1#msg59237 yeah I seen that. In my case, do I add this code somewhere (for my required fields Amount and Tax) begin Calculated := True; FieldKind := fkCalculated; FieldName := Amount + '_AsCurrency'; Name := Amount; DataSet := memOrderGridTemp1; end; begin Calculated := True; FieldKind := fkCalculated; FieldName := Tax + '_AsCurrency'; Name := Tax; DataSet := memOrderGridTemp1; end; second question, do I first 'add' these fields with the table Field Editor first? Regards, Pat |
Fri, Jan 11 2008 6:06 PM | Permanent Link |
Pat | >Tim,
> >><< I have a disk table (with 2 calculated fields) and I want the equivalent >>in a memory table. What I have coded so far gives me all the fields except >>the Calculated ones. I searched the newsgroup, but still cannot get it >>working. >> >> >>See here: >> >>http://www.elevatesoft.com/scripts/newsgrp.dll?action=openmsg&group=5&msg=59237&page=1#msg59237 > >yeah I seen that. In my case, do I add this code somewhere (for my >required fields Amount and Tax) > > begin > Calculated := True; > FieldKind := fkCalculated; > FieldName := Amount + '_AsCurrency'; > Name := Amount; > DataSet := memOrderGridTemp1; > end; > > begin > Calculated := True; > FieldKind := fkCalculated; > FieldName := Tax + '_AsCurrency'; > Name := Tax; > DataSet := memOrderGridTemp1; > end; looks like I cannot slot it into my Reversed Engineered code like it is, so I guess arrange it in an Add('......') went to (this is v4 but I am on v3, but should not be too far off the mark) http://www.elevatesoft.com/scripts/manual.dll?action=mancompmethod&id=dbisam4&product=d&version=6&comp=TDBISAMFieldDefs&method=Add Looked for a 'Calculated=True' property but cannot see one. Am I on the right path here? |
Sat, Jan 12 2008 2:56 AM | Permanent Link |
Pat | got a bit further, but still not worjking:
with memOrderGridTemp1 do begin with FieldDefs do begin Clear; Add('OrderGridID',ftAutoInc,0,False); Add('OrderID',ftInteger,0,False); Add('Description',ftMemo,0,False); Add('Description2',ftString,80,False); Add('Qty',ftFloat,0,False); Add('Rate',ftCurrency,0,False); Add('Amount',ftCurrency,0,False); Add('GST',ftCurrency,0,False); end; with IndexDefs do begin Clear; Add('','OrderGridID',[ixPrimary,ixUnique]); Add('Owner','OrderID',[]); end; if not Exists then CreateTable; end; Amount := TFloatField.create(memOrderGridTemp1); with Amount do begin FieldName:= 'Amount'; Calculated := True; //Currency := True; DataSet :=memOrderGridTemp1; Name :=memOrderGridTemp1.Name + FieldName; memOrderGridTemp1.FieldDefs.Add(Name, ftCurrency, 0, False); end; |
Sat, Jan 12 2008 1:17 PM | Permanent Link |
"Robert" | "Pat" <pat@downunder.com> wrote in message news:a8sgo35kf79g7djsjo327a1cd3mkjq2ji0@4ax.com... > got a bit further, but still not worjking: > 1. Create the table on disk with DBSYS 2. Put a tTable component in your datamodule, point it to the table created in step 1 3. Add all fields using field editor, including calculated fields. 4. Change the database of the tTable to memory 5. Erase the table created in step 1. Robert |
Sun, Jan 13 2008 7:01 AM | Permanent Link |
Pat | Robert,
>1. Create the table on disk with DBSYS >2. Put a tTable component in your datamodule, point it to the table created >in step 1 >3. Add all fields using field editor, including calculated fields. >4. Change the database of the tTable to memory >5. Erase the table created in step 1. thanks for that Now when my application starts, it complains Engine Error #11010 - table (that I deleted in step 5) does not exist. It displays this error when I open a form and am making the datamodule's MEMORY table active (I am using the table with a grid). Maybe I have not done something somewhere else? |
Sun, Jan 13 2008 9:11 AM | Permanent Link |
"Robert" | "Pat" <pat@downunder.com> wrote in message news:hrtjo39bs8rf9b6fpf11887sk17l7rmbru@4ax.com... > Robert, > >>1. Create the table on disk with DBSYS >>2. Put a tTable component in your datamodule, point it to the table >>created >>in step 1 >>3. Add all fields using field editor, including calculated fields. >>4. Change the database of the tTable to memory >>5. Erase the table created in step 1. > > thanks for that > > Now when my application starts, it complains Engine Error #11010 - > table (that I deleted in step 5) does not exist. It displays this > error when I open a form and am making the datamodule's MEMORY table > active (I am using the table with a grid). > > Maybe I have not done something somewhere else? You have to create the memory table. Either with a query "select into memory\mytable" or, if you just want an empty table, with a MyTable.CreateTable where mytable is your tTable component's name. If you create the table with a query, remember to close the query before you open the table. Robert |
Sun, Jan 13 2008 2:56 PM | Permanent Link |
Pat | >> Maybe I have not done something somewhere else?
> >You have to create the memory table. Either with a query "select into >memory\mytable" or, if you just want an empty table, with a >MyTable.CreateTable where mytable is your tTable component's name. If you >create the table with a query, remember to close the query before you open >the table. OK, and how do I create the calculated fields with these methods? |
Mon, Jan 14 2008 9:47 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Pat,
<< OK, and how do I create the calculated fields with these methods? >> The same way that Robert indicated before: http://www.elevatesoft.com/scripts/newsgrp.dll?action=openmsg&group=5&msg=60301&page=1#msg60301 The only difference between disk-based tables and in-memory tables is that you need to create the in-memory table when the application starts before you can open it. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Tuesday, September 17, 2024 at 04:19 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |