Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

@@IDENTITY question

7 posts in General Discussion Last posting was on 2011-10-19 05:01:30.0Z
Daniel Jenkins Posted on 2011-10-18 09:58:28.0Z
From: Daniel Jenkins <dj@gmail.com>
User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: @@IDENTITY question
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4e9d4dc4@forums-1-dub>
Date: 18 Oct 2011 02:58:28 -0700
X-Trace: forums-1-dub 1318931908 10.22.241.152 (18 Oct 2011 02:58:28 -0700)
X-Original-Trace: 18 Oct 2011 02:58:28 -0700, vip152.sybase.com
Lines: 10
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30608
Article PK: 73500

ASE 12.5.3 12461

Hi I have a table with an identity column. When I insert a new record I
would like to know what the new value of the identity column inserted is
so I immediately call SELECT @@identity but I always get a return value
of 0 (zero). Any ideas?

Thanks in advance,

Daniel.


Rob V Posted on 2011-10-18 10:13:47.0Z
From: Rob V <rob@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY>
Reply-To: rob@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY
Organization: Sypron BV
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: @@IDENTITY question
References: <4e9d4dc4@forums-1-dub>
In-Reply-To: <4e9d4dc4@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4e9d515b$1@forums-1-dub>
Date: 18 Oct 2011 03:13:47 -0700
X-Trace: forums-1-dub 1318932827 10.22.241.152 (18 Oct 2011 03:13:47 -0700)
X-Original-Trace: 18 Oct 2011 03:13:47 -0700, vip152.sybase.com
Lines: 35
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30609
Article PK: 73498


On 18-Oct-2011 11:58, Daniel Jenkins wrote:
> ASE 12.5.3 12461
>
> Hi I have a table with an identity column. When I insert a new record
> I would like to know what the new value of the identity column
> inserted is so I immediately call SELECT @@identity but I always get a
> return value of 0 (zero). Any ideas?
>
> Thanks in advance,
>
> Daniel.

I'm guessing you have other SQL statements in between the insert and the
select.
Can you post a (simplified) exmaple of the code that shows the problem?

--
HTH,

Rob V.
-----------------------------------------------------------------
Rob Verschoor

Certified Sybase Professional DBA for ASE 15.0/12.5/12.0/11.5/11.0
and Replication Server 15.0.1/12.5 // TeamSybase

Author of Sybase books (order online at www.sypron.nl/shop):
"Tips, Tricks& Recipes for Sybase ASE" (ASE 15 edition)
"The Complete Sybase ASE Quick Reference Guide"
"The Complete Sybase Replication Server Quick Reference Guide"

rob@NO.SPAM.sypron.nl | www.sypron.nl | Twitter: @rob_verschoor
Sypron B.V., The Netherlands | Chamber of Commerce 27138666
-----------------------------------------------------------------


Daniel Jenkins Posted on 2011-10-18 10:32:09.0Z
From: Daniel Jenkins <dj@gmail.com>
User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: @@IDENTITY question
References: <4e9d4dc4@forums-1-dub> <4e9d515b$1@forums-1-dub>
In-Reply-To: <4e9d515b$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4e9d55a9$1@forums-1-dub>
Date: 18 Oct 2011 03:32:09 -0700
X-Trace: forums-1-dub 1318933929 10.22.241.152 (18 Oct 2011 03:32:09 -0700)
X-Original-Trace: 18 Oct 2011 03:32:09 -0700, vip152.sybase.com
Lines: 57
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30610
Article PK: 73501


On 18/10/2011 14:13, Rob V wrote:
> On 18-Oct-2011 11:58, Daniel Jenkins wrote:
>> ASE 12.5.3 12461
>>
>> Hi I have a table with an identity column. When I insert a new record
>> I would like to know what the new value of the identity column
>> inserted is so I immediately call SELECT @@identity but I always get a
>> return value of 0 (zero). Any ideas?
>>
>> Thanks in advance,
>>
>> Daniel.
>
> I'm guessing you have other SQL statements in between the insert and the
> select.
> Can you post a (simplified) exmaple of the code that shows the problem?
>

Hi Rob,

I'm actually a PB developer and this is my code (contactsmst also has an
identity column conpk that gets updated with the next value automatically):

...start of code

string ls_sql
int li_conpk_new

ls_sql = 'SELECT @@identity into :li_conpk_new'

INSERT INTO contactsmst
( cname,
cmobileno,
ctypecd,
desig,
sectioncd,
createduid,
createddt )
VALUES ( :ls_cname,
:ls_cmobileno,
:ll_ctypecd,
:ls_desig,
:ll_sectioncd,
:gs_uid,
:ldt_dt ) ;

EXECUTE IMMEDIATE :ls_sql USING SQLCA;
MessageBox('idnty', string(li_conpk_new))

.....end

The value stored in li_conpk_new is always 0 even though the table
contactsmst has the inserted record with the next identity value as
expected.

Thanks for your time and help - much appreciated.

Daniel.


Daniel Jenkins Posted on 2011-10-18 11:07:31.0Z
From: Daniel Jenkins <dj@gmail.com>
User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: @@IDENTITY question
References: <4e9d4dc4@forums-1-dub> <4e9d515b$1@forums-1-dub> <4e9d55a9$1@forums-1-dub>
In-Reply-To: <4e9d55a9$1@forums-1-dub>
Content-Type: multipart/mixed; boundary="------------090909080605060607020309"
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4e9d5df3@forums-1-dub>
Date: 18 Oct 2011 04:07:31 -0700
X-Trace: forums-1-dub 1318936051 10.22.241.152 (18 Oct 2011 04:07:31 -0700)
X-Original-Trace: 18 Oct 2011 04:07:31 -0700, vip152.sybase.com
Lines: 315
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30611
Article PK: 73506


On 18/10/2011 14:32, Daniel Jenkins wrote:
> On 18/10/2011 14:13, Rob V wrote:
>> On 18-Oct-2011 11:58, Daniel Jenkins wrote:
>>> ASE 12.5.3 12461
>>>
>>> Hi I have a table with an identity column. When I insert a new record
>>> I would like to know what the new value of the identity column
>>> inserted is so I immediately call SELECT @@identity but I always get a
>>> return value of 0 (zero). Any ideas?
>>>
>>> Thanks in advance,
>>>
>>> Daniel.
>>
>> I'm guessing you have other SQL statements in between the insert and the
>> select.
>> Can you post a (simplified) exmaple of the code that shows the problem?
>>
> Hi Rob,
>
> I'm actually a PB developer and this is my code (contactsmst also has an
> identity column conpk that gets updated with the next value automatically):
>
> ...start of code
>
> string ls_sql
> int li_conpk_new
>
> ls_sql = 'SELECT @@identity into :li_conpk_new'
>
> INSERT INTO contactsmst
> ( cname,
> cmobileno,
> ctypecd,
> desig,
> sectioncd,
> createduid,
> createddt )
> VALUES ( :ls_cname,
> :ls_cmobileno,
> :ll_ctypecd,
> :ls_desig,
> :ll_sectioncd,
> :gs_uid,
> :ldt_dt ) ;
>
> EXECUTE IMMEDIATE :ls_sql USING SQLCA;
> MessageBox('idnty', string(li_conpk_new))
>
> .....end
>
> The value stored in li_conpk_new is always 0 even though the table
> contactsmst has the inserted record with the next identity value as
> expected.
>
> Thanks for your time and help - much appreciated.
>
> Daniel.

Hi Rob,

I've just established that ASE actually works fine, I'm just not able to
get the value in PowerBuilder. I'll head off to the PB newsgroups and
try there.

Thanks again,

Daniel.

identity.png

Rob V Posted on 2011-10-18 12:10:16.0Z
From: Rob V <rob@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY>
Reply-To: rob@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY
Organization: Sypron BV
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: @@IDENTITY question
References: <4e9d4dc4@forums-1-dub> <4e9d515b$1@forums-1-dub> <4e9d55a9$1@forums-1-dub> <4e9d5df3@forums-1-dub>
In-Reply-To: <4e9d5df3@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4e9d6ca8@forums-1-dub>
Date: 18 Oct 2011 05:10:16 -0700
X-Trace: forums-1-dub 1318939816 10.22.241.152 (18 Oct 2011 05:10:16 -0700)
X-Original-Trace: 18 Oct 2011 05:10:16 -0700, vip152.sybase.com
Lines: 95
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30612
Article PK: 73502


On 18-Oct-2011 13:07, Daniel Jenkins wrote:
> On 18/10/2011 14:32, Daniel Jenkins wrote:
>> On 18/10/2011 14:13, Rob V wrote:
>>> On 18-Oct-2011 11:58, Daniel Jenkins wrote:
>>>> ASE 12.5.3 12461
>>>>
>>>> Hi I have a table with an identity column. When I insert a new record
>>>> I would like to know what the new value of the identity column
>>>> inserted is so I immediately call SELECT @@identity but I always get a
>>>> return value of 0 (zero). Any ideas?
>>>>
>>>> Thanks in advance,
>>>>
>>>> Daniel.
>>>
>>> I'm guessing you have other SQL statements in between the insert and
>>> the
>>> select.
>>> Can you post a (simplified) exmaple of the code that shows the problem?
>>>
>> Hi Rob,
>>
>> I'm actually a PB developer and this is my code (contactsmst also has an
>> identity column conpk that gets updated with the next value
>> automatically):
>>
>> ...start of code
>>
>> string ls_sql
>> int li_conpk_new
>>
>> ls_sql = 'SELECT @@identity into :li_conpk_new'
>>
>> INSERT INTO contactsmst
>> ( cname,
>> cmobileno,
>> ctypecd,
>> desig,
>> sectioncd,
>> createduid,
>> createddt )
>> VALUES ( :ls_cname,
>> :ls_cmobileno,
>> :ll_ctypecd,
>> :ls_desig,
>> :ll_sectioncd,
>> :gs_uid,
>> :ldt_dt ) ;
>>
>> EXECUTE IMMEDIATE :ls_sql USING SQLCA;
>> MessageBox('idnty', string(li_conpk_new))
>>
>> .....end
>>
>> The value stored in li_conpk_new is always 0 even though the table
>> contactsmst has the inserted record with the next identity value as
>> expected.
>>
>> Thanks for your time and help - much appreciated.
>>
>> Daniel.
> Hi Rob,
>
> I've just established that ASE actually works fine, I'm just not able
> to get the value in PowerBuilder. I'll head off to the PB newsgroups
> and try there.
>
> Thanks again,
>
> Daniel.

The question is what actual SQL Statements this is translated to. One
way to find out would be the ASE table monSysSQLText. But it may be
simpler to create a stored procedure doing the insert and the select,
and call that from PB. That way you have full control over the SQL code.

--
HTH,

Rob V.
-----------------------------------------------------------------
Rob Verschoor

Certified Sybase Professional DBA for ASE 15.0/12.5/12.0/11.5/11.0
and Replication Server 15.0.1/12.5 // TeamSybase

Author of Sybase books (order online at www.sypron.nl/shop):
"Tips, Tricks& Recipes for Sybase ASE" (ASE 15 edition)
"The Complete Sybase ASE Quick Reference Guide"
"The Complete Sybase Replication Server Quick Reference Guide"

rob@NO.SPAM.sypron.nl | www.sypron.nl | Twitter: @rob_verschoor
Sypron B.V., The Netherlands | Chamber of Commerce 27138666
-----------------------------------------------------------------


Bret Halford Posted on 2011-10-18 15:40:25.0Z
From: Bret Halford <bret@sybase.com>
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: @@IDENTITY question
References: <4e9d4dc4@forums-1-dub> <4e9d515b$1@forums-1-dub> <4e9d55a9$1@forums-1-dub> <4e9d5df3@forums-1-dub> <4e9d6ca8@forums-1-dub>
In-Reply-To: <4e9d6ca8@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4e9d9de9$1@forums-1-dub>
Date: 18 Oct 2011 08:40:25 -0700
X-Trace: forums-1-dub 1318952425 10.22.241.152 (18 Oct 2011 08:40:25 -0700)
X-Original-Trace: 18 Oct 2011 08:40:25 -0700, vip152.sybase.com
Lines: 105
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30613
Article PK: 73503


On 10/18/2011 6:10 AM, Rob V wrote:
> On 18-Oct-2011 13:07, Daniel Jenkins wrote:
>> On 18/10/2011 14:32, Daniel Jenkins wrote:
>>> On 18/10/2011 14:13, Rob V wrote:
>>>> On 18-Oct-2011 11:58, Daniel Jenkins wrote:
>>>>> ASE 12.5.3 12461
>>>>>
>>>>> Hi I have a table with an identity column. When I insert a new record
>>>>> I would like to know what the new value of the identity column
>>>>> inserted is so I immediately call SELECT @@identity but I always get a
>>>>> return value of 0 (zero). Any ideas?
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>> Daniel.
>>>>
>>>> I'm guessing you have other SQL statements in between the insert and
>>>> the
>>>> select.
>>>> Can you post a (simplified) exmaple of the code that shows the problem?
>>>>
>>> Hi Rob,
>>>
>>> I'm actually a PB developer and this is my code (contactsmst also has an
>>> identity column conpk that gets updated with the next value
>>> automatically):
>>>
>>> ...start of code
>>>
>>> string ls_sql
>>> int li_conpk_new
>>>
>>> ls_sql = 'SELECT @@identity into :li_conpk_new'
>>>
>>> INSERT INTO contactsmst
>>> ( cname,
>>> cmobileno,
>>> ctypecd,
>>> desig,
>>> sectioncd,
>>> createduid,
>>> createddt )
>>> VALUES ( :ls_cname,
>>> :ls_cmobileno,
>>> :ll_ctypecd,
>>> :ls_desig,
>>> :ll_sectioncd,
>>> :gs_uid,
>>> :ldt_dt ) ;
>>>
>>> EXECUTE IMMEDIATE :ls_sql USING SQLCA;
>>> MessageBox('idnty', string(li_conpk_new))
>>>
>>> .....end
>>>
>>> The value stored in li_conpk_new is always 0 even though the table
>>> contactsmst has the inserted record with the next identity value as
>>> expected.
>>>
>>> Thanks for your time and help - much appreciated.
>>>
>>> Daniel.
>> Hi Rob,
>>
>> I've just established that ASE actually works fine, I'm just not able
>> to get the value in PowerBuilder. I'll head off to the PB newsgroups
>> and try there.
>>
>> Thanks again,
>>
>> Daniel.
>
> The question is what actual SQL Statements this is translated to. One
> way to find out would be the ASE table monSysSQLText. But it may be
> simpler to create a stored procedure doing the insert and the select,
> and call that from PB. That way you have full control over the SQL code.
>

Hm. I actually would not expect other statements in between to affect
@@identity as long as they did not involve an identity column (and even
if they did, I would not expect a zero value). In other words, I expect
@@identity to contain the most recently inserted identity value for this
connection. There was a bug in 1501-1503 which resulted in @@identity
being zeroed at times (CR 553428, actually opened by Rob, fixed in
15.0.3 ESD 3) - but the ASE version here is 12.5.x so that doesn't
apply and I don't find any relevant CRs for this version.

I'd normally only expect @@identity to show zero for a connection that
hadn't yet inserted any identity value. Now I'm not at all a
powerbuilder developer, but did a quick sanity check in the docs -
isn't the "USING SQLCA" syntax specifying using a particular connection
to ASE? Any chance this is a different connection than the default
connections used for the INSERT?

A quick way to check that would be to substitute @@spid into the
script, both as a value inserted into a column of the table
and the value retrieved by the EXECUTE IMMEDIATE - if these show
values, then your code is using two different connections to ASE.

Cheers,
-bret


Daniel Jenkins Posted on 2011-10-19 05:01:30.0Z
From: Daniel Jenkins <dj@gmail.com>
User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: @@IDENTITY question
References: <4e9d4dc4@forums-1-dub> <4e9d515b$1@forums-1-dub> <4e9d55a9$1@forums-1-dub> <4e9d5df3@forums-1-dub> <4e9d6ca8@forums-1-dub> <4e9d9de9$1@forums-1-dub>
In-Reply-To: <4e9d9de9$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4e9e59aa@forums-1-dub>
Date: 18 Oct 2011 22:01:30 -0700
X-Trace: forums-1-dub 1319000490 10.22.241.152 (18 Oct 2011 22:01:30 -0700)
X-Original-Trace: 18 Oct 2011 22:01:30 -0700, vip152.sybase.com
Lines: 131
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30616
Article PK: 73505

Thanks Rob & Bret,

Jason over in the PB general newsgroup reminded me of the PB Dynamic SQL
Format 3 (Result-set statements in which the input parameters and
result-set columns are known at compile time.)

http://manuals.sybase.com/onlinebooks/group-pbarc/pbw0500e/psref/@Generic__BookTextView/9819;pt=10812

This code did the trick:

DECLARE my_cursor DYNAMIC CURSOR FOR SQLSA ;
PREPARE SQLSA FROM "SELECT @@identity" ;
OPEN DYNAMIC my_cursor ;
FETCH my_cursor INTO :li_conpk_new ;
CLOSE my_cursor ;

Thanks again,

Daniel.

On 18/10/2011 19:40, Bret Halford wrote:
> On 10/18/2011 6:10 AM, Rob V wrote:
>> On 18-Oct-2011 13:07, Daniel Jenkins wrote:
>>> On 18/10/2011 14:32, Daniel Jenkins wrote:
>>>> On 18/10/2011 14:13, Rob V wrote:
>>>>> On 18-Oct-2011 11:58, Daniel Jenkins wrote:
>>>>>> ASE 12.5.3 12461
>>>>>>
>>>>>> Hi I have a table with an identity column. When I insert a new record
>>>>>> I would like to know what the new value of the identity column
>>>>>> inserted is so I immediately call SELECT @@identity but I always
>>>>>> get a
>>>>>> return value of 0 (zero). Any ideas?
>>>>>>
>>>>>> Thanks in advance,
>>>>>>
>>>>>> Daniel.
>>>>>
>>>>> I'm guessing you have other SQL statements in between the insert and
>>>>> the
>>>>> select.
>>>>> Can you post a (simplified) exmaple of the code that shows the
>>>>> problem?
>>>>>
>>>> Hi Rob,
>>>>
>>>> I'm actually a PB developer and this is my code (contactsmst also
>>>> has an
>>>> identity column conpk that gets updated with the next value
>>>> automatically):
>>>>
>>>> ...start of code
>>>>
>>>> string ls_sql
>>>> int li_conpk_new
>>>>
>>>> ls_sql = 'SELECT @@identity into :li_conpk_new'
>>>>
>>>> INSERT INTO contactsmst
>>>> ( cname,
>>>> cmobileno,
>>>> ctypecd,
>>>> desig,
>>>> sectioncd,
>>>> createduid,
>>>> createddt )
>>>> VALUES ( :ls_cname,
>>>> :ls_cmobileno,
>>>> :ll_ctypecd,
>>>> :ls_desig,
>>>> :ll_sectioncd,
>>>> :gs_uid,
>>>> :ldt_dt ) ;
>>>>
>>>> EXECUTE IMMEDIATE :ls_sql USING SQLCA;
>>>> MessageBox('idnty', string(li_conpk_new))
>>>>
>>>> .....end
>>>>
>>>> The value stored in li_conpk_new is always 0 even though the table
>>>> contactsmst has the inserted record with the next identity value as
>>>> expected.
>>>>
>>>> Thanks for your time and help - much appreciated.
>>>>
>>>> Daniel.
>>> Hi Rob,
>>>
>>> I've just established that ASE actually works fine, I'm just not able
>>> to get the value in PowerBuilder. I'll head off to the PB newsgroups
>>> and try there.
>>>
>>> Thanks again,
>>>
>>> Daniel.
>>
>> The question is what actual SQL Statements this is translated to. One
>> way to find out would be the ASE table monSysSQLText. But it may be
>> simpler to create a stored procedure doing the insert and the select,
>> and call that from PB. That way you have full control over the SQL code.
>>
>
>
> Hm. I actually would not expect other statements in between to affect
> @@identity as long as they did not involve an identity column (and even
> if they did, I would not expect a zero value). In other words, I expect
> @@identity to contain the most recently inserted identity value for this
> connection. There was a bug in 1501-1503 which resulted in @@identity
> being zeroed at times (CR 553428, actually opened by Rob, fixed in
> 15.0.3 ESD 3) - but the ASE version here is 12.5.x so that doesn't
> apply and I don't find any relevant CRs for this version.
>
> I'd normally only expect @@identity to show zero for a connection that
> hadn't yet inserted any identity value. Now I'm not at all a
> powerbuilder developer, but did a quick sanity check in the docs -
> isn't the "USING SQLCA" syntax specifying using a particular connection
> to ASE? Any chance this is a different connection than the default
> connections used for the INSERT?
>
> A quick way to check that would be to substitute @@spid into the
> script, both as a value inserted into a column of the table
> and the value retrieved by the EXECUTE IMMEDIATE - if these show
> values, then your code is using two different connections to ASE.
>
> Cheers,
> -bret
>
>
>