The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Auto-Increment ID Fields...
Posted: 13 Feb 07 12:26 PM
|
fiogf49gjkf0d Hi folks,
I'm trying to use the auto-increment feature (we have slx 6.2.3) on a custom table I created, but slx isn't cooperating.
Quick backround: custom table - contact_commissions, joined 1:many to contact on contactid. Simple. One key field, contact_commissionsid was created, and I have checked the auto-increment box on this field in database manage. I checked sectabledefs, and autoincrement is marked T for this field. Everything looks good to me.
So I fire up administrator, go to sql and try: insert into contact_commissions (contactid, field1, field2, field3) select contactid, field1, field2, field3 from where
and promptly get the "Cannot insert the value NULL into column contact_commissionsid TABLE: nha_slx.sysdba.contact_commissions. Column does not accept nulls" error.
What am I doing wrong? contact_commissions is the key field, I'm executing the sql from inside the slx administrator, and I know the field is set to auto-increment. Shouldn't slx be creating the contact_commissionsid field values for this table as the records insert?
Any clues appreciated.
Don |
|
|
|
Re: Auto-Increment ID Fields...
Posted: 04 Mar 07 9:53 PM
|
fiogf49gjkf0d Don, You've got to use the application functions to get the ID for the record. Application.BasicFunctions.GetIDFor("Contact_Commission")
From SQL, you're not specifying a value for the CONTACT_COMMISIONID, so you're getting the NULL insert error.
HTH, Ron |
|
|
|
Re: Auto-Increment ID Fields...
Posted: 05 Mar 07 11:35 AM
|
fiogf49gjkf0d Have you checked the sectabledefs.autoincrement to see if the field does in fact show it is marked for autoincrement?
This works for me and your steps you outline doesn't seem like anything is missing. |
|
|
|
Re: Auto-Increment ID Fields...
Posted: 04 Jun 07 3:32 PM
|
Hello, I have the same issue: the field is checked as autoincrement and the sectabledefs.autoincrement = 'T' My table was originally designed as not having the table id column being auto incremented. Now we need to do bulk inserts into the table and I've modified field's property. Insert is failing because of the null values in the table id column.
Thanks, Lana |
|
|
|
Re: Auto-Increment ID Fields...
Posted: 04 Jun 07 3:35 PM
|
You want to ensure that you're *not* inserting NULL values into the ID field. It should be omitted completely from the insert statement or you'll get the error you mention.
For example, do this:
insert into mytable (field1, field2) values ('Value 1', 'Value 2')
Do not do this:
insert into mytable (mytableid, field1, field2) values (null, 'Value 1', 'Value 2')
Does that make sense? |
|
|
|
Re: Auto-Increment ID Fields...
Posted: 04 Jun 07 3:44 PM
|
Ryan, Thanks! I did exclude the tableid from my statement. By the way, I am using SLX 7.0.1 and SQL Server 2005 as our host db. Could my errors refer to the fact that originally my table was not defined as having auto-increment fields? Thanks! Lana |
|
|
| |
|
Re: Auto-Increment ID Fields...
Posted: 05 Jun 07 10:16 AM
|
I did restart SLXSystem to no effect. I also tried to clear all data from the table before running an insert but this didn't help either. So, I guess I'll try to trick SLX by finding a way to insert unique values and to generate ID column. I don't actually need this column in my custom table. Is there a way to get rid of it?
Thanks! |
|
|
|
Re: Auto-Increment ID Fields...
Posted: 05 Jun 07 1:29 PM
|
I recall having to reboot the SLX Server machine. I may have overlooked a service or something, but the reboot worked just fine too 
Timmus |
|
|
|
Re: Auto-Increment ID Fields...
Posted: 06 Jun 07 6:44 AM
|
Correct.. too many folks think that rebooting their client system is the answer.. it's the Slx Server that needs to be re-booted. -- rjl |
|
|
|