> First off, in your case the IBUpdateSQL is not needed. It is more there
for the
> people who need to update multiple tables in the OnUpdateRecord event.
You
> aren't doing this and the straight InsertSQL is all you need.
> The bug it not in the GeneratorField property. It is in your definition.
Your
> domain for the USERID column is
> CREATE DOMAIN TUSERID AS INTEGER
> CHECK (VALUE > 1000);
> yet the Generator is starting at 1. Try executing
> set generator usid_gen to 1000
> now run and it should work just fine. Does for me. It was your check
> constraint that was firing because you did not set the generator to start
at
> 1000.
> Lars wrote:
> > Hi
> > I get the error 'Violation of PRIMARY or UNIQUE KEY constraint INTEG_45
on
> > table USERS' when i try to add a record to a empty table. Probably I
have
> > missunderstod something and I hope somebody can help me.
> > The field USERID is the primary field and I have created a generator in
IB
> > and set it to 1001 in order to get unique autoincremented numbers to
insert.
> > As I can understand, the property GeneratorField of TIBDataSet has been
> > added
> > to help inserting values in PRIMARY KEYS without using triger procedures
in
> > IB6.
> > My IBDataSet1 is connected to a IBDatabase1
> > IBDataset1 is linked to IBTransaction1 and IBUpdateSQL1
> > CachedUpdate = True
> > GeneratorField = USID_GEN -> USERID By 1 ; Applay Event OnPost
> > InsertSQL = insert into USERS
> > (USERID, USERNAME, FIRSTNAME, LASTNAME, EMAIL, PWD)
> > values
> > (:USERID, :USERNAME, :FIRSTNAME, :LASTNAME, :EMAIL, :PWD)
> > IBTransaction1.Params set to
> > read_committed
> > rec_version
> > nowait
> > IBUpdateSQL insertSQL is the same as that of IBDataSet1
> > My procedure to insert a new record looks like this:
> > with IBDataSet1 do begin
> > Append;
> > FieldByName('USERNAME').AsString := UserName;
> > FieldByName('FIRSTNAME').AsString := FirstName;
> > FieldByName('LASTNAME').AsString := LastName;
> > FieldByName('EMAIL').AsString := Email;
> > FieldByName('PWD').AsString := pwd;
> > Post;
> > ApplyUpdates; {here the violation error occure}
> > end;
> > Table declaration looks like this:
> > CREATE DOMAIN TEMAILADR AS VARCHAR(40);
> > CREATE DOMAIN TFIRSTNAME AS VARCHAR(15);
> > CREATE DOMAIN TLASTNAME AS VARCHAR(20);
> > CREATE DOMAIN TUSERID AS INTEGER
> > CHECK (VALUE > 1000);
> > CREATE DOMAIN TUSERNAME AS VARCHAR(15);
> > CREATE TABLE USERS
> > (
> > USERID TUSERID NOT NULL,
> > USERNAME TUSERNAME NOT NULL,
> > FIRSTNAME TFIRSTNAME,
> > LASTNAME TLASTNAME,
> > EMAIL TEMAILADR,
> > PWD VARCHAR(12) NOT NULL,
> > UNIQUE (USERNAME),
> > PRIMARY KEY (USERID)
> > );
> > CREATE GENERATOR USID_GEN;
> > I use Delphi 5.01, IB6 dialect 1, IBX 4.41
> > By the way
> > When is the the protected procedure DoOnNewRecord called in the
> > TIBCustomDataSet
> > /Lars
> --
> Jeff Overcash (TeamB) | Talk about failure
> (Please do not email | To fall is not to fail
> me directly unless | Failure isn't about falling down
> asked. Thank You) | Failure is staying down (Marillion)