I am not sure it's a good idea to extend the sqlca structure.
AFAIK, sqlca structure should follow some standard definition and is used in different SQL client languages.
But seems all DB vendors have implemented their own "standard".
Original Message:
Sent: Mon December 16, 2024 07:09 AM
From: Vicente Salvador Cubedo
Subject: ESQL/C 15 and sqlca.sqlerrd[1] for new BIGSERIAL
My two cents,
Best Solution can be to do not change current sqlerrd specification
sqlca.sqlerrd[1] stores last serial or 0
and simply add one more component to the array, so:
sqlca.sqlerrd[7] stores last bigserial or 0
This column types are not the same, so it makes sense to me to have diferent process logic and diferent positions in memory structure.
------------------------------
Vicente Salvador Cubedo
Software Architect
DEISTER, S.A.
Barcelona
+34 932063298
Original Message:
Sent: Mon December 16, 2024 02:00 AM
From: Sebastien FLAESCH
Subject: ESQL/C 15 and sqlca.sqlerrd[1] for new BIGSERIAL
Hello Andreas, Art,
To me, having 2 auto-incremented columns (SERIAL and BIGSERIAL) in the same table looks strange.
Using more than 1 SERIAL or more that 1 BIGSERIAL results in error:
-362: Can have only one column of serial/(serial8 or bigserial) type.
So you can create this table:
create table tab1 ( s1 serial, bs1 bigserial, name varchar(50) );
But not this one:
create table tab1 ( s1 serial, s2 serial, name varchar(50) );
Why?
The fact that a SERIAL + BIGSERIAL is allowed in the same table looks more like a design mistake.
As you certainly know, each sqlca.sqlerrd[] element has a specific purpose:
https://www.ibm.com/docs/en/informix-servers/15.0.0?topic=structure-fields-sqlca
and the size of the sqlca.sqlerrd[] array is 6 (from 0 to 5 in C, from 1 to 6 in 4GL)
Art: If you suggest to have an 7th element at C index 6, I am not sure this is a good idea.
For now, the most important is to get the last generated SERIAL or BIGSERIAL in the C-style sqlca.sqlerrd[1], to help 99% of cases where tables have one single auto-incremented column.
For those rare cases where there is a SERIAL column AND a BIGSERIAL column in the same table, they can use DBINFO('sqlca.sqlerrd1') in addition to DBINFO('bigserial'):
> create table tab1 ( s1 serial(100), bs1 bigserial(100000000), name varchar(50) );Table created.> insert into tab1 (name) values ('aaa');1 row(s) inserted.> select dbinfo('sqlca.sqlerrd1'), dbinfo('bigserial');(expression) (expression) 100 1000000001 row(s) retrieved.
Seb
------------------------------
Sebastien FLAESCH
Original Message:
Sent: Sun December 15, 2024 04:04 PM
From: Art Kagel
Subject: ESQL/C 15 and sqlca.sqlerrd[1] for new BIGSERIAL
Andreas:
That's interesting. Being able to have both a SERIAL and a BIGSERIAL or SERIAL8 brings up something my mother-in-law used to say: "Just because you can doesn't mean that you should!"
It has nothing to do with the discussion you started here, but I struggle to think of a valid reason to have two different autoincrement type columns in a singlet table as a database designer.
The obvious solution would be to take the opportunity of having to move to CSDK v15.0 to expand the sqlca.sqlerrd array to provide a second serial value field. But, you do make a good point certainly about having to modify code because you have altered a serial key to a bigserial key.
How about this as a solution: Treat sqlca.sqlerrd[1] as the value of the first autoincrement column in a table's definition and say sqlca.sqlerrd[6] as the value of the second autoincrement column. Then existing code doesn't break as long as it is recompiled/linked with the new libraries, or the compatibility layer I was discussing becomes a possibility, while new code takes advantage of the new expanded structure to avoid the extra round trip of calling DBINFO() as Sebastien called it.
Then it does not matter if the first column is serial or bigserial and the second is the other autoincrement type, and it doesn't matter if there is only a serial type that is later altered to bigserial.
Art
------------------------------
Art S. Kagel, President and Principal Consultant
ASK Database Management Corp.
www.askdbmgt.com
Original Message:
Sent: Sun December 15, 2024 03:37 PM
From: Andreas Legner
Subject: ESQL/C 15 and sqlca.sqlerrd[1] for new BIGSERIAL
While certainly seeing the point, there's a little caveat:
- a table can have simultaneously a serial and a bigserial or serial8 column - not sure how realistic or who'd do this, but it is possible, and therefor the two had to be returned separately, in two different sqlerrd fields
- so, even if a table only has one serial type column, the application might not know, or had to be made to know, which one it is ... and had to check both sqlerrd fields
- and there's at least the theoretical case where a serial has to change into bigserial on database side, but application couldn't change (and hopefully is flexible enough to also accept bigserial), so would want to expect the new serial value in sqlerrd[1] no matter what
How would you/anyone like to see this solved?
Cheers,
Andreas
------------------------------
Andreas Legner
Informix Dev
HCL Software
Original Message:
Sent: Sun December 15, 2024 12:26 PM
From: Sebastien FLAESCH
Subject: ESQL/C 15 and sqlca.sqlerrd[1] for new BIGSERIAL
Thank you Art for creating INFX-I-655!
Obviously, saving another round-trip with the server to execute an additional SELECT DBINFO('bigserial') would be great!
For those which do not use SERIAL/BIGSERIAL columns:
Getting the new generated number after INSERT is a must for applications, as this column is usually the primary key.
The portable SQL solution is to use SEQUENCEs, but that is more coding and not required if the only target SQL engine type is Informix.
Seb
------------------------------
Sebastien FLAESCH
Original Message:
Sent: Sun December 15, 2024 08:02 AM
From: Art Kagel
Subject: ESQL/C 15 and sqlca.sqlerrd[1] for new BIGSERIAL
Sebastien:
RFE # INFX-I-655 created:
V15 sqlca structure to report BIGSERIAL & SERIAL8 value assigned by INSERT
In versions of the engine prior to v15.0 & CSDK library versions prior to v15.0, the SQLCA structure fields were int4 and could not hold the values returned from inserting to a BIGSERIAL or SERIAL8 column requiring a separate call to the DBINFO() function to retrieve the last inserted value. However, in the v15.0 engine and libraries, the fields of SQLCA are int8 type so it is now possible for an INSERT to return even BIGSERIAL & SERIAL8 values.
------------------------------
Art S. Kagel, President and Principal Consultant
ASK Database Management Corp.
www.askdbmgt.com
Original Message:
Sent: Sat December 14, 2024 04:37 AM
From: Sebastien FLAESCH
Subject: ESQL/C 15 and sqlca.sqlerrd[1] for new BIGSERIAL
Hello Art,
I tried to add that idea here:
https://communities.actian.com/s/actian-communities-ideas?category=OneDB%2F+HCL+Informix
But it hangs...
Maybe it's no longer possible with my current Actian/HCL account (we will renew the partnership)
I wish I could spend more time on coding instead of struggling with all these procedures.
Last day, I also wanted to report the bug we found in CONNECT TO.
Not possible for now.
Seb
------------------------------
Sebastien FLAESCH
Original Message:
Sent: Fri December 13, 2024 12:11 PM
From: Art Kagel
Subject: ESQL/C 15 and sqlca.sqlerrd[1] for new BIGSERIAL
Sebastien:
Yes, that is expected. You still have to call dbinfo() to get the BIGSERIAL or (heaven forbid) SERIAL8 value assigned to a new row.
Perhaps a Feature Request to include BIGSERIAL and SERIAL8 in sqlca when appropriate should be created in the Ideas page?
Art
------------------------------
Art S. Kagel, President and Principal Consultant
ASK Database Management Corp.
www.askdbmgt.com
Original Message:
Sent: Fri December 13, 2024 12:03 PM
From: Sebastien FLAESCH
Subject: ESQL/C 15 and sqlca.sqlerrd[1] for new BIGSERIAL
Hello,
Since ESQL/C sqlca.sqlerrd[6] is now an int8 array, I expected to get the last generated bigserial in this register, after doing an INSERT.
Seems it is not the case...
I see a value zero in sqlca.sqlerrd[1] , is this normal?
Seb
------------------------------
Sebastien FLAESCH
------------------------------