Re: Unable to insert row into table with serialized primary key
Mike Aubury <[email protected]> Thu, 11 Feb 2021 16:41:33 +0000
| Newsgroups | gmane.comp.lang.4gl.aubit.general |
|---|---|
| Message-ID | <CAGAq4WEesc68F=o9HLg=UdqUSn_d9KmBtMWNivSGpPkR3m-MRQ@mail.gmail.com> |
If you're using Informix - the code would work as expected. When using postgresql - you need to set up a few things on that column See the README in the aubit4glsrc/lib/libsql/postgresql directory There is a "fix_serial.4gl" program you can try which does this automatically. Note however - this approach wont work for temp tables.. On Thu, 11 Feb 2021 at 16:35, James B. Byrne via Aubit4gl-discuss < [email protected]> wrote: > in Exercise 9 of Informix by Example one is required to insert rows into a > table (customers) having a serialized primary key: > > CREATE TABLE public.customer > ( > customer_num integer NOT NULL > DEFAULT nextval('customer_customer_num_seq'::regclass), > . . . > CONSTRAINT customer_pkey PRIMARY KEY (customer_num), > . . . > > The code provided in the exercise is: > WHENEVER ERROR CONTINUE > INSERT INTO CUSTOMER > VALUES ( > 0, > gr_customer.fname, > gr_customer.lname, > gr_customer.company, > gr_customer.address1, > gr_customer.address2, > gr_customer.city, > gr_customer.state, > gr_customer.zipcode, > gr_customer.phone > ) > WHENEVER ERROR STOP > > IF (status < 0) THEN > ERROR status USING "-<<<<<<<<<<<", ": Unable to complete customer > insert." > > This always returns "-239" (duplicate key violates unique constraint) from > 'postgres8' once the first new record has been added. That first row is > assigned the value 0 indicating that the serialization is not being used. > The > SQLCA array that is returned is empty. > > How does one insert rows into tables with serialized columns using > Aubit4GL? > > > -- > *** e-Mail is NOT a SECURE channel *** > Do NOT transmit sensitive data via e-Mail > Unencrypted messages have no legal claim to privacy > Do NOT open attachments nor follow links sent by e-Mail > > James B. Byrne mailto:[email protected] > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3C3 > > > > _______________________________________________ > Aubit4gl-discuss mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss > _______________________________________________ Aubit4gl-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss