Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM Client/Server » View Thread |
Messages 1 to 9 of 9 total |
AutoInc field value not showing - inserting |
Wed, Aug 1 2007 6:42 PM | Permanent Link |
"John Postnikoff" | I use the value of an auto-incremented field to create a resullt of another field joined together. The value of the AutoInc field does not appear until after I save the record. I would like to have the value of the AutoInc field insert into the record before hand to compete my calculation. e.g. OrderTableShipmentID.asinteger := OrdertableTerminalID.asinteger * 100000 + OrdertableWaybillNumber.asinteger; Thanks for any help JP |
Thu, Aug 2 2007 4:18 AM | Permanent Link |
Eryk Bottomley | John,
> after I save the record. I would like to have the value of the AutoInc > field insert into the record before hand to compete my calculation. AutoInc values are assigned during the "Post" operation so they don't exist until the record is saved. Workarounds for a case like yours include managing your own sequence numbers or else posting the record and immediately re-editing it to force the autoinc to be assigned. Eryk |
Fri, Aug 10 2007 11:04 AM | Permanent Link |
Chris Erdal | Eryk Bottomley <no@way.com> wrote in news:901D3F6E-B657-4915-A446-
B870086E663F@news.elevatesoft.com: > John, > >> after I save the record. I would like to have the value of the AutoInc >> field insert into the record before hand to compete my calculation. > > > AutoInc values are assigned during the "Post" operation so they don't > exist until the record is saved. > Eryk > What about setting AutoGenerateValue to True for the key field(s)? (assuming they are persistent) It seems from the help file that this may in some cases be a solution, as Delphi does the automatic Query after Post for you. -- Chris (XP-Pro + Delphi 7 Architect + DBISAM 4.25 build 4 + EDB 1.04 build 3) |
Fri, Aug 10 2007 12:12 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Chris,
<< What about setting AutoGenerateValue to True for the key field(s)? (assuming they are persistent) >> The AutoGenerateValue property doesn't apply to DBISAM or EDB. -- Tim Young Elevate Software www.elevatesoft.com |
Fri, Aug 10 2007 12:36 PM | Permanent Link |
Chris Erdal | "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in
news:47ECB90B-4B86-4F9C-94ED-8D88A912D643@news.elevatesoft.com: > Chris, > ><< What about setting AutoGenerateValue to True for the key field(s)? > (assuming they are persistent) >> > > The AutoGenerateValue property doesn't apply to DBISAM or EDB. > Thanks for the clarification, Tim. But isn't the AutoInc value visible once the Post has been executed? the Delphi help file says: --------------------------------8<----------------------------------- AutoGenerateValue is not always required. Fields with an AutoGenerateValue property of arNone may still be updated if the driver supplies metadata that indicates it has a default value or an autoincrement value. However, it is good practice to supply this information because not all drivers supply this metadata. --------------------------------8<----------------------------------- I've never noticed any problem with this, and assumed DBISAM fell into the category that "supplies metadata that indicates it has a default value or an autoincrement value". Perhaps I've just inadvertently avoided the need for it... -- Chris (XP-Pro + Delphi 7 Architect + DBISAM 4.25 build 4 + EDB 1.04 build 3) |
Mon, Aug 13 2007 4:00 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Chris,
<< But isn't the AutoInc value visible once the Post has been executed? >> Yes it is. -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Aug 14 2007 5:37 AM | Permanent Link |
Chris Erdal | "John Postnikoff" <postnikoff@hotmail.com> wrote in
news:F34030CC-0CCD-4246-8375-5B79FD653B30@news.elevatesoft.com: > e.g. OrderTableShipmentID.asinteger := OrdertableTerminalID.asinteger > * 100000 + OrdertableWaybillNumber.asinteger; John, In view of the discussion above, it looks as if a simple solution would be an AfterInsertTrigger to assign the value. -- Chris (XP-Pro + Delphi 7 Architect + DBISAM 4.25 build 4 + EDB 1.04 build 3) |
Tue, Aug 28 2007 11:51 AM | Permanent Link |
"David Farrell-Garcia" | John Postnikoff wrote:
> > I use the value of an auto-incremented field to create a resullt of > another field joined together. The value of the AutoInc field does > not appear until after I save the record. I would like to have the > value of the AutoInc field insert into the record before hand to > compete my calculation. > > e.g. OrderTableShipmentID.asinteger := > OrdertableTerminalID.asinteger * 100000 + > OrdertableWaybillNumber.asinteger; > > Thanks for any help > > JP You cannot use the autoinc field in a master detail situation until you have posted the master record. If you think about it a bit you will see why this must be so. hint: think of a multi-user application. Since it seems as if your problem is that you want to establish a master-detail relationship at runtime, you have a few options. 1. Post the Master record, refresh to get the new autoinc ID field, then proceed. downside is that if you wish to cancel you have to deal with the already posted master record. The only downside to this method is the extra trip to the database. 2. Use something other then an autoinc as your key field, such as a Guild which you can easily create client side. This is a very easy way to do it and is robust in that GUIDs are unique so merging databases in the future is an option. Downside is that they make no sense to end users so must be hidden. 3. create your own integer based ID generator. This is very common method, however, if yours is a multi user application right some robust code to lock the table holding the next ID while in use. 4. Use ClientDatasets and use a negative number as your first autoinc ID such as -1 and decrease this by one for each new master record. When the changes are applied the negative number will be replaced automatcally by the correct autoinc value. This works perfectly, however, if you need to display the autoinc ID to the user, then you have to post the master record and refresh it anyway rendering this method unnecessary. -- David Farrell-Garcia Whidbey Island Software, LLC |
Tue, Aug 28 2007 11:53 AM | Permanent Link |
"David Farrell-Garcia" | David Farrell-Garcia wrote:
> right some robust > code Geeze. Did I really say "right" some robust code? -- David Farrell-Garcia Whidbey Island Software, LLC |
This web page was last updated on Saturday, April 27, 2024 at 08:52 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |