Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 10 of 12 total |
Autoinc availability? |
Mon, Aug 4 2008 11:10 AM | Permanent Link |
"aroberts" | I am using an autoinc field as a primary key. Since this is for an
order-entry application, I would like to be able to display the value (which is the order number) to the user. However, if I insert a new record and post it, then read the autoinc field, it always returns zero. I am using transactions, and have not yet committed at that point. Is that the problem, and if so, is there a better way of doing this? I am using DBIsam 4.21 build 6. Thanks. |
Mon, Aug 4 2008 2:30 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | << I am using an autoinc field as a primary key. Since this is for an order-entry application, I would like to be able to display the value (which is the order number) to the user. However, if I insert a new record and post it, then read the autoinc field, it always returns zero. I am using transactions, and have not yet committed at that point. Is that the problem, and if so, is there a better way of doing this? I am using DBIsam 4.21 build 6. >> Are you inserting the record using the TDBISAMTable.Insert method ? If so, then the autoinc field should automatically be populated after the insert is complete. -- Tim Young Elevate Software www.elevatesoft.com |
Mon, Aug 4 2008 2:47 PM | Permanent Link |
"Robert" | "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message news:8673A59E-5804-4BB2-A1ED-2A1985F64A8F@news.elevatesoft.com... > > << I am using an autoinc field as a primary key. Since this is for an > order-entry application, I would like to be able to display the value > (which is the order number) to the user. However, if I insert a new > record and post it, then read the autoinc field, it always returns zero. > I am using transactions, and have not yet committed at that point. Is > that the problem, and if so, is there a better way of doing this? I am > using DBIsam 4.21 build 6. >> > > Are you inserting the record using the TDBISAMTable.Insert method ? If > so, then the autoinc field should automatically be populated after the > insert is complete. > I'm not 100% sure, but could the problem be that the field is being populated with a zero before you post the new record? Do you have a default value, or some such thing that would automatically populate the field? Robert |
Mon, Aug 4 2008 4:23 PM | Permanent Link |
"aroberts" | "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message news:8673A59E-5804-4BB2-A1ED-2A1985F64A8F@news.elevatesoft.com... > > << I am using an autoinc field as a primary key. Since this is for an > order-entry application, I would like to be able to display the value > (which is the order number) to the user. However, if I insert a new > record and post it, then read the autoinc field, it always returns zero. > I am using transactions, and have not yet committed at that point. Is > that the problem, and if so, is there a better way of doing this? I am > using DBIsam 4.21 build 6. >> > > Are you inserting the record using the TDBISAMTable.Insert method ? If > so, then the autoinc field should automatically be populated after the > insert is complete. > > -- > Tim Young > Elevate Software > www.elevatesoft.com I have been using the Append method. Is there a difference in the availabilty of the autoinc value? |
Mon, Aug 4 2008 4:25 PM | Permanent Link |
"aroberts" | "Robert" <ngsemail2005withoutthis@yahoo.com.ar> wrote in message news:881F3F11-F4DE-4E88-9EB7-7FDD2CF4EE05@news.elevatesoft.com... > > "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message > news:8673A59E-5804-4BB2-A1ED-2A1985F64A8F@news.elevatesoft.com... >> >> << I am using an autoinc field as a primary key. Since this is for an >> order-entry application, I would like to be able to display the value >> (which is the order number) to the user. However, if I insert a new >> record and post it, then read the autoinc field, it always returns zero. >> I am using transactions, and have not yet committed at that point. Is >> that the problem, and if so, is there a better way of doing this? I am >> using DBIsam 4.21 build 6. >> >> >> Are you inserting the record using the TDBISAMTable.Insert method ? If >> so, then the autoinc field should automatically be populated after the >> insert is complete. >> > > I'm not 100% sure, but could the problem be that the field is being > populated with a zero before you post the new record? Do you have a > default value, or some such thing that would automatically populate the > field? > > Robert No, it's just the autoinc value, there is no default value on the table. Thanks for the reply. > > > |
Mon, Aug 4 2008 5:24 PM | Permanent Link |
"Robert" | "aroberts" <aroberts@roboticstech.com> wrote in message news:C076B69C-717C-4975-8BBF-3F01472DB0D6@news.elevatesoft.com... > > "Robert" <ngsemail2005withoutthis@yahoo.com.ar> wrote in message > news:881F3F11-F4DE-4E88-9EB7-7FDD2CF4EE05@news.elevatesoft.com... >> >> >> I'm not 100% sure, but could the problem be that the field is being >> populated with a zero before you post the new record? Do you have a >> default value, or some such thing that would automatically populate the >> field? >> >> Robert > > No, it's just the autoinc value, there is no default value on the table. > Thanks for the reply. > Well, it's definitely something you're doing, because if what you have is these sequence of events: StartTransaction; Table.Insert; Table.Post; at this point, the autoinc field is populated. Guaranteed. Either you are initializing the field to zero, or you're closing the table before you test the new value, or something of the sort. Robert |
Mon, Aug 4 2008 6:34 PM | Permanent Link |
"aroberts" | "Robert" <ngsemail2005withoutthis@yahoo.com.ar> wrote in message news:37E81E77-01F8-440A-B6CE-5BAA9A597710@news.elevatesoft.com... > > "aroberts" <aroberts@roboticstech.com> wrote in message > news:C076B69C-717C-4975-8BBF-3F01472DB0D6@news.elevatesoft.com... >> >> "Robert" <ngsemail2005withoutthis@yahoo.com.ar> wrote in message >> news:881F3F11-F4DE-4E88-9EB7-7FDD2CF4EE05@news.elevatesoft.com... >>> >>> >>> I'm not 100% sure, but could the problem be that the field is being >>> populated with a zero before you post the new record? Do you have a >>> default value, or some such thing that would automatically populate the >>> field? >>> >>> Robert >> >> No, it's just the autoinc value, there is no default value on the table. >> Thanks for the reply. >> > > Well, it's definitely something you're doing, because if what you have is > these sequence of events: > > StartTransaction; > Table.Insert; > Table.Post; > > at this point, the autoinc field is populated. Guaranteed. Either you are > initializing the field to zero, or you're closing the table before you > test the new value, or something of the sort. > > Robert > Oh yes, I quite am sure that it is something that I am doing wrong--I just haven't identified it yet What you have described above is the exactly sequence that I am using (except that I'm using the append method). There are no other contravening activities against the dataset, and there is no default value assigned in the table (particularly since I want it to be autoincrementing). This is the code: //############### dm1.DBISAMDatabase1.StartTransaction; dm1.tblMaster.Append; dm1.tblMasterName.AsString := dm1.tblInfoClientName.AsString; dm1.tblMasterCustNum.AsInteger := dm1.tblInfoClientCustNum.AsInteger; dm1.tblMasterSalesperson.AsString := UName; dm1.tblMaster.Post; CurQuote := dm1.tblMasterQuoteNum.asInteger; //############### CurQuote always returns 'zero'. If I use the "LastAutoIncValue" method, then I get the next autoinc number, but is this a good way to do this in a multi-user environment? What would happen if another user were to enter an order? Would he not return an identical number, thereby violating the uniqueness of the key? Since I have not yet committed, isn't that LastIncValue available to all? Thanks again. |
Mon, Aug 4 2008 10:57 PM | Permanent Link |
"Robert" | "aroberts" <aroberts@roboticstech.com> wrote in message news:6444F6AE-55A3-4CE6-A8AB-BDC427AB7FEB@news.elevatesoft.com... > > What you have described above is the exactly sequence that I am using Why don't you trace the table field, especially right before and right after the post? > > > If I use the "LastAutoIncValue" method, then I get the next autoinc > number, Nah, don't sweep the problem under the rug, you'll just make it worse. It can't be that complicated. Maybe you are not even getting to the post, maybe there is an exception that you are bypassing? Is it possible the databse is already in transaction? Robert |
Tue, Aug 5 2008 6:29 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | << I have been using the Append method. Is there a difference in the availabilty of the autoinc value? >> Nope, no difference at all. They both should work fine. I'm with Robert on this one - you're going to have to trace through things and see if anything unexpected is occurring with the autoinc field. Or you might want to just take out the code that you listed and pop it into a simple application that only performs the append. If it works there, then you at least know where to go from there. -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Aug 5 2008 8:35 AM | Permanent Link |
"Robert" | "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message news:80552AA9-FF34-406C-89F7-11606F0DDA9D@news.elevatesoft.com... > > << I have been using the Append method. Is there a difference in the > availabilty of the autoinc value? >> > > Nope, no difference at all. They both should work fine. > > I'm with Robert on this one - you're going to have to trace through things There is a way to get this effect (I think) but it is rather bizarre. If you have a filter on the table that filters out any autoincs > 0. The moment you post, your record is gone. The null field as integer returns zero. Robert |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Sunday, May 5, 2024 at 07:30 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |