Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
anil kuttappan wrote:
>
> Hi ,
>
> I would like somebody to help me out with this.
>
> I have a table with serial column.
> In a multiuser environment suppose user A inserts
> a row inthe table and wants to retrieve the serial
> value for the row he just inserted, how do i get it.
> considering the fact that user B might have also
> inserted a row while user A did a select to find its
> value.
>
> So the question is how to retrieve the serial value
> for the row which User A inserted.
>
> I know locking the concerned table and doing a select
> to get the last value followed by an insert of a new
> row and a commit is one alternative,
> but i would like to know if there is any other way
> out.
This depends on what development language you are using. In ESQL/C
the data structure sqlca contains the array sqlerrd. Ssqlca.sqlerrd[1]
contains the serial number assigned to the last row inserted by THIS
session. In 4GL it is sqlca.sqlerrd[2]. In ODBC or SPL you have to
use the DBINFO function:
SELECT DBINFO( 'sqlca.sqlerrd1' )
INTO last_serial_num
FROM systables where tabid = 99;
--
Art S. Kagel & Family
kagel@erols.com
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.