Solved

Informix - sqlca.sqlerrd1 variable?

Posted on 1997-08-01
1
1,351 Views
Last Modified: 2008-07-03
The following SQL is working as expected;

INSERT INTO TABLE(COLUMN1) VALUES (VALUE1);

This INSERT is inserting a column, COLUMN1, and a serialized column,
COLUMN2, not shown. COLUMN2 gets incremented automatically.

SELECT SERIALIZEDCOLUMN FROM TABLE WHERE SERIALIZEDCOLUMN =
DBINFO('sqlca.sqlerrd1');

This SELECT statement returns the thread specific SERIALIZEDCOLUMN that was
just inserted.  Everything is working as I would expect.

QUESTION?

Is there any other way to get the sqlca.sqlerrd1 variable, without issuing
a SQL statement.  A "C" routine would be nice, or any other method.

The problem is I want to read this value directly without issuing a second
SQL statement.

I am using VB5 as the VCL.

Any help would be greatly appreciated.

Carl

0
Comment
Question by:cfulton
1 Comment
 
LVL 9

Accepted Solution

by:
cymbolic earned 50 total points
ID: 1025201
I don't think there is another way.  You have to read it from the database, because it doesn't exist until the row is added to the table.  It's not in your resultset in memory to be accessed. It get's generated from internal system tables by your server when the row is written. For some additional insight into what your access method sees and is doing, set logging/trace on in your ODBC Connection  using your ODBC connection  Manager, then review the details of what's actually transpiring when you do one of these inserts.  I don't think you'll see the serialized number ever coming back to your VB app.

Also, you can't even "read ahead" and guess that the next number will be one higher than the current maximum number, because that doesn't work in a multiusr environment.

If you're really desparate, don't use an autonumber field.  Set up your own control table to control and select new numbers, or use a very large random random generated floating point number to serialize.  That way you are in control, since you hand out the numbers, not your server.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now