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.

Issue with user_id() function returning wrong user now and then...

9 posts in General Discussion Last posting was on 2009-09-01 16:10:49.0Z
Liezl Posted on 2009-08-25 11:04:27.0Z
Sender: 2b47.4a939e29.846930886@sybase.com
From: Liezl
Newsgroups: sybase.public.ase.general
Subject: Issue with user_id() function returning wrong user now and then...
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4a93c53b.3176.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 25 Aug 2009 04:04:27 -0700
X-Trace: forums-1-dub 1251198267 10.22.241.41 (25 Aug 2009 04:04:27 -0700)
X-Original-Trace: 25 Aug 2009 04:04:27 -0700, 10.22.241.41
Lines: 110
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28212
Article PK: 77456

We sometimes, very intermittently, get the wrong user
returned with the user_id() function on ASE 12.5.3 when used
with a trigger.

When a user connects and save information a trigger gets
executed that logs info for auditing purposes.

The trigger selects the user_id() of the current user logged
in. It has been found that the user_id() returned form the
internal function, occasionally was the wrong or an
non-existing userid.

IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
BEGIN
DROP TRIGGER dbo.Tr_flwsIns
IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
PRINT '<<< FAILED DROPPING TRIGGER dbo.Tr_flwsIns
>>>'
ELSE
PRINT '<<< DROPPED TRIGGER dbo.Tr_flwsIns >>>'
END
go

CREATE TRIGGER dbo.Tr_flwsIns
ON dbo.DealInstrumentFlows
FOR insert
AS
/*****************************************************************************
* Trigger: Tr_flwsIns
* author: ?
* date: ?
* purpose: To insert into the TODAY..Flows_Log with the
Flows
* that where inserted and writes an Action_Type of
'I' for inserted.
* It also inserts a date that the Flow is written
to the
* Flows_Log table.
*****************************************************************************/

/*
** Declare all variables
*/


DECLARE @uid int
DECLARE @User int
DECLARE @Date datetime

/* Determine the User performing the action */


SELECT @uid = user_id()

SELECT @User = People_Number
FROM Users
WHERE uid = @uid

SELECT @User = 71
WHERE @User is null

SELECT @Date = GetDate()

INSERT WORKSPACE..TestUserCapture (Date, Uid, User_Number)
SELECT getdate(), @uid, @User


INSERT TODAY..Flows_Log
( Flow_Number,
Flow_Type,
Flow_Usage,
Transact_Type,
Action_Type,
Action_Date,
User_People_Number,
Date_Printed,
Insight_Date,
Date_Sent_To_Cats)
SELECT Flow_Number,
Flow_Type,
Flow_Usage,
Transact_Type,
'I',
@Date,
@User,
null,
null,
null
from inserted


IF @@error <> 0
begin
rollback transaction
raiserror 20001 'an error occurred while inserting
into the Flows_Log for inserted Flows.
All Transactions will be rolled back.'
return
end
go
IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
PRINT '<<< CREATED TRIGGER dbo.Tr_flwsIns >>>'
ELSE
PRINT '<<< FAILED CREATING TRIGGER dbo.Tr_flwsIns >>>'
go


Any ideas?
Thanks
Liezl


"Mark A. Parsons" <iron_horse Posted on 2009-08-25 12:23:15.0Z
From: "Mark A. Parsons" <iron_horse@no_spamola.compuserve.com>
User-Agent: Thunderbird 1.5.0.10 (Windows/20070221)
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: Issue with user_id() function returning wrong user now and then...
References: <4a93c53b.3176.1681692777@sybase.com>
In-Reply-To: <4a93c53b.3176.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Antivirus: avast! (VPS 090821-0, 08/21/2009), Outbound message
X-Antivirus-Status: Clean
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4a93d7b3$1@forums-1-dub>
Date: 25 Aug 2009 05:23:15 -0700
X-Trace: forums-1-dub 1251202995 10.22.241.152 (25 Aug 2009 05:23:15 -0700)
X-Original-Trace: 25 Aug 2009 05:23:15 -0700, vip152.sybase.com
Lines: 167
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28215
Article PK: 77459

I found a solved case @ sybase.com that mentions user_id()/user_name() returning wrong values in a 12.5.0.3 dataserver.
The associated CR (389277) is mentioned as 'to be fixed' in ASE 12.5.4.

There aren't any notes that describe any details of the case so I'm not sure under what situation the problem occurs.

I'd suggest you open a case with Sybase TechSupport to see if they can verify that you've run into the same (or
another?) issue.

-------------------

In the mean time, without access to the actual data I can only throw a few questions into the ring ...

- have you verified that you have a valid mapping for every user_id() value in your Users table? what do you get from
the following query:

==========================
use <dbname>
go

select *
from sysusers s
where not exists(select u.uid
from Users u
where u.uid = s.uid)
and suid != -2
go
==========================

- in the case of non-existing userid's, is your trigger inserting User_Number = 71? what does the following query return?

==========================
use <dbname>
go

select user_name(71)
go
==========================

- can you provide a sample (or two) problematic cases? in particular I'd be looking for the name of the database user
(not their login name), and their sysusers info, eg:

==========================
use <dbname>
go

select *
from sysusers
where name = <database_user_name>
go
==========================

- also provide your exact ASE version (select @@version)

Liezl wrote:
> We sometimes, very intermittently, get the wrong user
> returned with the user_id() function on ASE 12.5.3 when used
> with a trigger.
>
> When a user connects and save information a trigger gets
> executed that logs info for auditing purposes.
>
> The trigger selects the user_id() of the current user logged
> in. It has been found that the user_id() returned form the
> internal function, occasionally was the wrong or an
> non-existing userid.
>
> IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
> BEGIN
> DROP TRIGGER dbo.Tr_flwsIns
> IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
> PRINT '<<< FAILED DROPPING TRIGGER dbo.Tr_flwsIns
>>>> '
> ELSE
> PRINT '<<< DROPPED TRIGGER dbo.Tr_flwsIns >>>'
> END
> go
>
> CREATE TRIGGER dbo.Tr_flwsIns
> ON dbo.DealInstrumentFlows
> FOR insert
> AS
> /*****************************************************************************
> * Trigger: Tr_flwsIns
> * author: ?
> * date: ?
> * purpose: To insert into the TODAY..Flows_Log with the
> Flows
> * that where inserted and writes an Action_Type of
> 'I' for inserted.
> * It also inserts a date that the Flow is written
> to the
> * Flows_Log table.
> *****************************************************************************/
>
> /*
> ** Declare all variables
> */
>
>
> DECLARE @uid int
> DECLARE @User int
> DECLARE @Date datetime
>
> /* Determine the User performing the action */
>
>
> SELECT @uid = user_id()
>
> SELECT @User = People_Number
> FROM Users
> WHERE uid = @uid
>
> SELECT @User = 71
> WHERE @User is null
>
> SELECT @Date = GetDate()
>
> INSERT WORKSPACE..TestUserCapture (Date, Uid, User_Number)
> SELECT getdate(), @uid, @User
>
>
> INSERT TODAY..Flows_Log
> ( Flow_Number,
> Flow_Type,
> Flow_Usage,
> Transact_Type,
> Action_Type,
> Action_Date,
> User_People_Number,
> Date_Printed,
> Insight_Date,
> Date_Sent_To_Cats)
> SELECT Flow_Number,
> Flow_Type,
> Flow_Usage,
> Transact_Type,
> 'I',
> @Date,
> @User,
> null,
> null,
> null
> from inserted
>
>
> IF @@error <> 0
> begin
> rollback transaction
> raiserror 20001 'an error occurred while inserting
> into the Flows_Log for inserted Flows.
> All Transactions will be rolled back.'
> return
> end
> go
> IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
> PRINT '<<< CREATED TRIGGER dbo.Tr_flwsIns >>>'
> ELSE
> PRINT '<<< FAILED CREATING TRIGGER dbo.Tr_flwsIns >>>'
> go
>
>
> Any ideas?
> Thanks
> Liezl


Bret Halford [Sybase] Posted on 2009-08-25 19:41:14.0Z
From: "Bret Halford [Sybase]" <bret@sybase.com>
Organization: Sybase, Inc.
User-Agent: Thunderbird 2.0.0.22 (Windows/20090605)
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: Issue with user_id() function returning wrong user now and then...
References: <4a93c53b.3176.1681692777@sybase.com> <4a93d7b3$1@forums-1-dub>
In-Reply-To: <4a93d7b3$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: <4a943e5a$1@forums-1-dub>
Date: 25 Aug 2009 12:41:14 -0700
X-Trace: forums-1-dub 1251229274 10.22.241.152 (25 Aug 2009 12:41:14 -0700)
X-Original-Trace: 25 Aug 2009 12:41:14 -0700, vip152.sybase.com
Lines: 21
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28216
Article PK: 77460


Mark A. Parsons wrote:
> I found a solved case @ sybase.com that mentions user_id()/user_name()
> returning wrong values in a 12.5.0.3 dataserver. The associated CR
> (389277) is mentioned as 'to be fixed' in ASE 12.5.4.
>
> There aren't any notes that describe any details of the case so I'm not
> sure under what situation the problem occurs.
>
> I'd suggest you open a case with Sybase TechSupport to see if they can
> verify that you've run into the same (or another?) issue.
>

It isn't CR 389277 (though that isn't fixed yet). The issue there is
with procedures created in other databases (sybsystemprocs, master) then
where they are executed (i.e. when a proc created in sybsystemprocs is
executed in database "production", user_id() may return the uid from
sybsystemprocs rather than the uid from production. Triggers are always
executed from the context of the database they were created in, so this
wouldn't be an issue for them.

-bret


Carl Kayser Posted on 2009-08-26 09:58:00.0Z
From: "Carl Kayser" <kayser_c@bls.gov>
Newsgroups: sybase.public.ase.general
References: <4a93c53b.3176.1681692777@sybase.com> <4a93d7b3$1@forums-1-dub> <4a943e5a$1@forums-1-dub>
Subject: Re: Issue with user_id() function returning wrong user now and then...
Lines: 32
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3598
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4a950728$1@forums-1-dub>
Date: 26 Aug 2009 02:58:00 -0700
X-Trace: forums-1-dub 1251280680 10.22.241.152 (26 Aug 2009 02:58:00 -0700)
X-Original-Trace: 26 Aug 2009 02:58:00 -0700, vip152.sybase.com
X-Authenticated-User: ase1251
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28220
Article PK: 77464


"Bret Halford [Sybase]" <bret@sybase.com> wrote in message
news:4a943e5a$1@forums-1-dub...
> Mark A. Parsons wrote:
>> I found a solved case @ sybase.com that mentions user_id()/user_name()
>> returning wrong values in a 12.5.0.3 dataserver. The associated CR
>> (389277) is mentioned as 'to be fixed' in ASE 12.5.4.
>>
>> There aren't any notes that describe any details of the case so I'm not
>> sure under what situation the problem occurs.
>>
>> I'd suggest you open a case with Sybase TechSupport to see if they can
>> verify that you've run into the same (or another?) issue.
>>
>
> It isn't CR 389277 (though that isn't fixed yet). The issue there is with
> procedures created in other databases (sybsystemprocs, master) then where
> they are executed (i.e. when a proc created in sybsystemprocs is
> executed in database "production", user_id() may return the uid from
> sybsystemprocs rather than the uid from production. Triggers are always
> executed from the context of the database they were created in, so this
> wouldn't be an issue for them.
>
> -bret

And the dbname, etc values will generally be wrong in this situation.
Auditing, say, sp_dropuser becomes pointless because the user name argument
for sp_adduser may be correct but the database name in the sysaudits tables
will be "sybsystemprocs". Unfortunately ISUG ER 2922 from August 2005
appears to be going nowhere. Grrrrr.


Carl Kayser Posted on 2009-08-26 10:51:17.0Z
From: "Carl Kayser" <kayser_c@bls.gov>
Newsgroups: sybase.public.ase.general
References: <4a93c53b.3176.1681692777@sybase.com> <4a93d7b3$1@forums-1-dub> <4a943e5a$1@forums-1-dub> <4a950728$1@forums-1-dub>
Subject: Re: Issue with user_id() function returning wrong user now and then...
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3598
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4a9513a5$1@forums-1-dub>
Date: 26 Aug 2009 03:51:17 -0700
X-Trace: forums-1-dub 1251283877 10.22.241.152 (26 Aug 2009 03:51:17 -0700)
X-Original-Trace: 26 Aug 2009 03:51:17 -0700, vip152.sybase.com
X-Authenticated-User: ase1251
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28221
Article PK: 77465


"Carl Kayser" <kayser_c@bls.gov> wrote in message
news:4a950728$1@forums-1-dub...
>
> "Bret Halford [Sybase]" <bret@sybase.com> wrote in message
> news:4a943e5a$1@forums-1-dub...
>> Mark A. Parsons wrote:
>>> I found a solved case @ sybase.com that mentions user_id()/user_name()
>>> returning wrong values in a 12.5.0.3 dataserver. The associated CR
>>> (389277) is mentioned as 'to be fixed' in ASE 12.5.4.
>>>
>>> There aren't any notes that describe any details of the case so I'm not
>>> sure under what situation the problem occurs.
>>>
>>> I'd suggest you open a case with Sybase TechSupport to see if they can
>>> verify that you've run into the same (or another?) issue.
>>>
>>
>> It isn't CR 389277 (though that isn't fixed yet). The issue there is
>> with procedures created in other databases (sybsystemprocs, master) then
>> where they are executed (i.e. when a proc created in sybsystemprocs is
>> executed in database "production", user_id() may return the uid from
>> sybsystemprocs rather than the uid from production. Triggers are always
>> executed from the context of the database they were created in, so this
>> wouldn't be an issue for them.
>>
>> -bret
>
> And the dbname, etc values will generally be wrong in this situation.
> Auditing, say, sp_dropuser becomes pointless because the user name
> argument for sp_adduser may be correct but the database name in the
> sysaudits tables will be "sybsystemprocs". Unfortunately ISUG ER 2922
> from August 2005 appears to be going nowhere. Grrrrr.
>

Obviously I did a mix-and-match with sp_adduser and sp_dropuser. the
complaint is still valid for both as well as many other "sp_" procs.


Liezl Posted on 2009-08-26 09:32:07.0Z
Sender: 2b47.4a939e29.846930886@sybase.com
From: Liezl
Newsgroups: sybase.public.ase.general
Subject: Re: Issue with user_id() function returning wrong user now and then...
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4a950117.7127.1681692777@sybase.com>
References: <4a93d7b3$1@forums-1-dub>
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 26 Aug 2009 02:32:07 -0700
X-Trace: forums-1-dub 1251279127 10.22.241.41 (26 Aug 2009 02:32:07 -0700)
X-Original-Trace: 26 Aug 2009 02:32:07 -0700, 10.22.241.41
Lines: 283
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28219
Article PK: 77462

Answers to the questions asked earlier
Thanks
Liezl

select *
from sysusers s
where not exists(select u.uid
from Users u
where u.uid = s.uid)
and suid != -2
go
(user identities disguised)
suid    uid     gid    name   
environ
-99     1437    16395  user1 [NULL]
40      222     16390  user2 [NULL]
116     778     16390  sqr [NULL]
487     506     16390  user4 [NULL]
506     526     16390  user5 [NULL]
523     542     16390  user6 [NULL]
555     575     16390  user7 [NULL]
568     588     16390  INSIGHT2    [NULL]
575     594     16390  user8 [NULL]
632     651     16390  user9 [NULL]
637     656     16390  user10 [NULL]
714     733     16390  user11 [NULL]
730     749     0      user12 [NULL]
739     758     16390  user13 [NULL]
777     797     16390  logical   
[NULL]
811     831     16390  user14 [NULL]
812     832     16390  NEWINSIGHT  [NULL]
856     877     16390  user15 [NULL]
859     880     16390  user16 [NULL]
890     913     0      user17 [NULL]
891     1693    16391  user18 [NULL]
892     915     0      user19 [NULL]
893     916     16390  user20 [NULL]
894     917     16390  user21 [NULL]
895     918     16390  user22 [NULL]
896     919     16390  user23 [NULL]
897     920     16390  user24 [NULL]
927     1589    16390  dummy1      [NULL]
930     951     0      IMS_MAIN_maint    [NULL]
936     956     16390  user25 [NULL]
940     1330    0      user26 [NULL]
968     987     0      user27 [NULL]
977     1590    16391  user28 [NULL]
1049    1067    16390  user29 [NULL]
1061    1260    16391  user30 [NULL]
1211    1226    16390  user31 [NULL]
1289    1307    16390  user32 [NULL]
1324    1450    16390  system_security   [NULL]
1327    1345    16390  user33 [NULL]
1377    1396    16391  user34 [NULL]
1418    1435    16395  user35 [NULL]
1420    1436    16395  user36 [NULL]
1421    1438    16395  user37 [NULL]
1422    1439    16395  user38 [NULL]
1423    1440    16395  user39 [NULL]
1431    1449    16390  user40 [NULL]
1453    1472    16390  user41 [NULL]
1474    1496    16390  user42 [NULL]
1485    1507    16390  user43 [NULL]
1505    1527    16390  user44 [NULL]
1506    1528    16390  user45 [NULL]
1513    1535    16390  user46 [NULL]
1514    1536    16390  user47 [NULL]
1523    1545    16390  user48 [NULL]
1588    1613    0      user49 [NULL]
1598    1623    16391  user50 [NULL]
1599    1624    16391  user51 [NULL]
1609    1667    16391  user52 [NULL]
1619    1644    16391  user53 [NULL]
1620    1645    16390  system_source [NULL]
1624    1648    16391  user54 [NULL]
1631    1655    16391  user55 [NULL]
1635    1659    16390  user56 [NULL]
1731    1757    16390  user57 [NULL]

select user_name(71)
go

NULL

It has happened to the following user sometime ago:
select *
from sysusers
where name = 'selliott'
go

suid uid gid name environ
1577 1604 16390 selliott [NULL]

L

> I found a solved case @ sybase.com that mentions
> user_id()/user_name() returning wrong values in a 12.5.0.3
> dataserver.
> The associated CR (389277) is mentioned as 'to be fixed'
> in ASE 12.5.4.
>
> There aren't any notes that describe any details of the
> case so I'm not sure under what situation the problem
> occurs.
>
> I'd suggest you open a case with Sybase TechSupport to see
> if they can verify that you've run into the same (or
> another?) issue.
>
> -------------------
>
> In the mean time, without access to the actual data I can
> only throw a few questions into the ring ...
>
> - have you verified that you have a valid mapping for
> every user_id() value in your Users table? what do you
> get from the following query:
>
>
==========================
> use <dbname>
> go
>
> select *
> from sysusers s
> where not exists(select u.uid
> from Users u
> where u.uid = s.uid)
> and suid != -2
> go
>
==========================
>
> - in the case of non-existing userid's, is your trigger
> inserting User_Number = 71? what does the following
query
> return?
>
>
==========================
> use <dbname>
> go
>
> select user_name(71)
> go
>
==========================
>
> - can you provide a sample (or two) problematic cases? in
> particular I'd be looking for the name of the database
> user (not their login name), and their sysusers info, eg:
>
>
==========================
> use <dbname>
> go
>
> select *
> from sysusers
> where name = <database_user_name>
> go
>
==========================
>
> - also provide your exact ASE version (select @@version)
>
>
>
>
> Liezl wrote:
> > We sometimes, very intermittently, get the wrong user
> > returned with the user_id() function on ASE 12.5.3 when
> > used with a trigger.
> >
> > When a user connects and save information a trigger gets
> > executed that logs info for auditing purposes.
> >
> > The trigger selects the user_id() of the current user
> > logged in. It has been found that the user_id() returned
> > form the internal function, occasionally was the wrong
> > or an non-existing userid.
> >
> > IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
> > BEGIN
> > DROP TRIGGER dbo.Tr_flwsIns
> > IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
> > PRINT '<<< FAILED DROPPING TRIGGER
> dbo.Tr_flwsIns >>>> '
> > ELSE
> > PRINT '<<< DROPPED TRIGGER dbo.Tr_flwsIns >>>'
> > END
> > go
> >
> > CREATE TRIGGER dbo.Tr_flwsIns
> > ON dbo.DealInstrumentFlows
> > FOR insert
> > AS
> >
> /*********************************************************
> > ******************** * Trigger: Tr_flwsIns
> > * author: ?
> > * date: ?
> > * purpose: To insert into the TODAY..Flows_Log with the
> > Flows
> > * that where inserted and writes an Action_Type
> > of 'I' for inserted.
> > * It also inserts a date that the Flow is
> > written to the
> > * Flows_Log table.
> >
> **********************************************************
> > *******************/
> > /*
> > ** Declare all variables
> > */
> >
> >
> > DECLARE @uid int
> > DECLARE @User int
> > DECLARE @Date datetime
> >
> > /* Determine the User performing the action */
> >
> >
> > SELECT @uid = user_id()
> >
> > SELECT @User = People_Number
> > FROM Users
> > WHERE uid = @uid
> >
> > SELECT @User = 71
> > WHERE @User is null
> >
> > SELECT @Date = GetDate()
> >
> > INSERT WORKSPACE..TestUserCapture (Date, Uid,
> > User_Number) SELECT getdate(), @uid, @User
> >
> >
> > INSERT TODAY..Flows_Log
> > ( Flow_Number,
> > Flow_Type,
> > Flow_Usage,
> > Transact_Type,
> > Action_Type,
> > Action_Date,
> > User_People_Number,
> > Date_Printed,
> > Insight_Date,
> > Date_Sent_To_Cats)
> > SELECT Flow_Number,
> > Flow_Type,
> > Flow_Usage,
> > Transact_Type,
> > 'I',
> > @Date,
> > @User,
> > null,
> > null,
> > null
> > from inserted
> >
> >
> > IF @@error <> 0
> > begin
> > rollback transaction
> > raiserror 20001 'an error occurred while inserting
> > into the Flows_Log for inserted Flows.
> > All Transactions will be rolled back.'
> > return
> > end
> > go
> > IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
> > PRINT '<<< CREATED TRIGGER dbo.Tr_flwsIns >>>'
> > ELSE
> > PRINT '<<< FAILED CREATING TRIGGER dbo.Tr_flwsIns
> > >>>' go
> >
> >
> > Any ideas?
> > Thanks
> > Liezl


"Mark A. Parsons" <iron_horse Posted on 2009-08-26 12:14:43.0Z
From: "Mark A. Parsons" <iron_horse@no_spamola.compuserve.com>
User-Agent: Thunderbird 1.5.0.10 (Windows/20070221)
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: Issue with user_id() function returning wrong user now and then...
References: <4a93d7b3$1@forums-1-dub> <4a950117.7127.1681692777@sybase.com>
In-Reply-To: <4a950117.7127.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Antivirus: avast! (VPS 090825-0, 08/25/2009), Outbound message
X-Antivirus-Status: Clean
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4a952733$1@forums-1-dub>
Date: 26 Aug 2009 05:14:43 -0700
X-Trace: forums-1-dub 1251288883 10.22.241.152 (26 Aug 2009 05:14:43 -0700)
X-Original-Trace: 26 Aug 2009 05:14:43 -0700, vip152.sybase.com
Lines: 293
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28223
Article PK: 77467

... not sure what the problem is (at this point).

You mention that the selliot user had a problem some time ago ... but it's hard to tell at this point if selliot's uid
was added (or updated) in the Users table since then. When the problem was occurring, did selliot's audit record get
set to 71 (unknown) or to some other number?

You've also got 5 dozen users in sysusers who aren't in your Users table, which I'm assuming should generate an audit
number = 71; do you consider 71 as an incorrect number?

Since users can be dropped/(re)added to a database, and obtain a different uid after such an action, I'd have to
question the process that keeps the Users table in sync. Could there be holes in this process that leads to unwanted
71's, or uid's not being inserted/updated properly if/when a user is dropped and/or (re)added?

Liezl wrote:
> Answers to the questions asked earlier
> Thanks
> Liezl
>
> select *
> from sysusers s
> where not exists(select u.uid
> from Users u
> where u.uid = s.uid)
> and suid != -2
> go
> (user identities disguised)
> suid uid gid name
> environ
> -99 1437 16395 user1 [NULL]
> 40 222 16390 user2 [NULL]
> 116 778 16390 sqr [NULL]
> 487 506 16390 user4 [NULL]
> 506 526 16390 user5 [NULL]
> 523 542 16390 user6 [NULL]
> 555 575 16390 user7 [NULL]
> 568 588 16390 INSIGHT2 [NULL]
> 575 594 16390 user8 [NULL]
> 632 651 16390 user9 [NULL]
> 637 656 16390 user10 [NULL]
> 714 733 16390 user11 [NULL]
> 730 749 0 user12 [NULL]
> 739 758 16390 user13 [NULL]
> 777 797 16390 logical
> [NULL]
> 811 831 16390 user14 [NULL]
> 812 832 16390 NEWINSIGHT [NULL]
> 856 877 16390 user15 [NULL]
> 859 880 16390 user16 [NULL]
> 890 913 0 user17 [NULL]
> 891 1693 16391 user18 [NULL]
> 892 915 0 user19 [NULL]
> 893 916 16390 user20 [NULL]
> 894 917 16390 user21 [NULL]
> 895 918 16390 user22 [NULL]
> 896 919 16390 user23 [NULL]
> 897 920 16390 user24 [NULL]
> 927 1589 16390 dummy1 [NULL]
> 930 951 0 IMS_MAIN_maint [NULL]
> 936 956 16390 user25 [NULL]
> 940 1330 0 user26 [NULL]
> 968 987 0 user27 [NULL]
> 977 1590 16391 user28 [NULL]
> 1049 1067 16390 user29 [NULL]
> 1061 1260 16391 user30 [NULL]
> 1211 1226 16390 user31 [NULL]
> 1289 1307 16390 user32 [NULL]
> 1324 1450 16390 system_security [NULL]
> 1327 1345 16390 user33 [NULL]
> 1377 1396 16391 user34 [NULL]
> 1418 1435 16395 user35 [NULL]
> 1420 1436 16395 user36 [NULL]
> 1421 1438 16395 user37 [NULL]
> 1422 1439 16395 user38 [NULL]
> 1423 1440 16395 user39 [NULL]
> 1431 1449 16390 user40 [NULL]
> 1453 1472 16390 user41 [NULL]
> 1474 1496 16390 user42 [NULL]
> 1485 1507 16390 user43 [NULL]
> 1505 1527 16390 user44 [NULL]
> 1506 1528 16390 user45 [NULL]
> 1513 1535 16390 user46 [NULL]
> 1514 1536 16390 user47 [NULL]
> 1523 1545 16390 user48 [NULL]
> 1588 1613 0 user49 [NULL]
> 1598 1623 16391 user50 [NULL]
> 1599 1624 16391 user51 [NULL]
> 1609 1667 16391 user52 [NULL]
> 1619 1644 16391 user53 [NULL]
> 1620 1645 16390 system_source [NULL]
> 1624 1648 16391 user54 [NULL]
> 1631 1655 16391 user55 [NULL]
> 1635 1659 16390 user56 [NULL]
> 1731 1757 16390 user57 [NULL]
>
> select user_name(71)
> go
>
> NULL
>
> It has happened to the following user sometime ago:
> select *
> from sysusers
> where name = 'selliott'
> go
>
> suid uid gid name environ
> 1577 1604 16390 selliott [NULL]
>
> L
>
>> I found a solved case @ sybase.com that mentions
>> user_id()/user_name() returning wrong values in a 12.5.0.3
>> dataserver.
>> The associated CR (389277) is mentioned as 'to be fixed'
>> in ASE 12.5.4.
>>
>> There aren't any notes that describe any details of the
>> case so I'm not sure under what situation the problem
>> occurs.
>>
>> I'd suggest you open a case with Sybase TechSupport to see
>> if they can verify that you've run into the same (or
>> another?) issue.
>>
>> -------------------
>>
>> In the mean time, without access to the actual data I can
>> only throw a few questions into the ring ...
>>
>> - have you verified that you have a valid mapping for
>> every user_id() value in your Users table? what do you
>> get from the following query:
>>
>>
> ==========================
>> use <dbname>
>> go
>>
>> select *
>> from sysusers s
>> where not exists(select u.uid
>> from Users u
>> where u.uid = s.uid)
>> and suid != -2
>> go
>>
> ==========================
>> - in the case of non-existing userid's, is your trigger
>> inserting User_Number = 71? what does the following
> query
>> return?
>>
>>
> ==========================
>> use <dbname>
>> go
>>
>> select user_name(71)
>> go
>>
> ==========================
>> - can you provide a sample (or two) problematic cases? in
>> particular I'd be looking for the name of the database
>> user (not their login name), and their sysusers info, eg:
>>
>>
> ==========================
>> use <dbname>
>> go
>>
>> select *
>> from sysusers
>> where name = <database_user_name>
>> go
>>
> ==========================
>> - also provide your exact ASE version (select @@version)
>>
>>
>>
>>
>> Liezl wrote:
>>> We sometimes, very intermittently, get the wrong user
>>> returned with the user_id() function on ASE 12.5.3 when
>>> used with a trigger.
>>>
>>> When a user connects and save information a trigger gets
>>> executed that logs info for auditing purposes.
>>>
>>> The trigger selects the user_id() of the current user
>>> logged in. It has been found that the user_id() returned
>>> form the internal function, occasionally was the wrong
>>> or an non-existing userid.
>>>
>>> IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
>>> BEGIN
>>> DROP TRIGGER dbo.Tr_flwsIns
>>> IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
>>> PRINT '<<< FAILED DROPPING TRIGGER
>> dbo.Tr_flwsIns >>>> '
>>> ELSE
>>> PRINT '<<< DROPPED TRIGGER dbo.Tr_flwsIns >>>'
>>> END
>>> go
>>>
>>> CREATE TRIGGER dbo.Tr_flwsIns
>>> ON dbo.DealInstrumentFlows
>>> FOR insert
>>> AS
>>>
>> /*********************************************************
>>> ******************** * Trigger: Tr_flwsIns
>>> * author: ?
>>> * date: ?
>>> * purpose: To insert into the TODAY..Flows_Log with the
>>> Flows
>>> * that where inserted and writes an Action_Type
>>> of 'I' for inserted.
>>> * It also inserts a date that the Flow is
>>> written to the
>>> * Flows_Log table.
>>>
>> **********************************************************
>>> *******************/
>>> /*
>>> ** Declare all variables
>>> */
>>>
>>>
>>> DECLARE @uid int
>>> DECLARE @User int
>>> DECLARE @Date datetime
>>>
>>> /* Determine the User performing the action */
>>>
>>>
>>> SELECT @uid = user_id()
>>>
>>> SELECT @User = People_Number
>>> FROM Users
>>> WHERE uid = @uid
>>>
>>> SELECT @User = 71
>>> WHERE @User is null
>>>
>>> SELECT @Date = GetDate()
>>>
>>> INSERT WORKSPACE..TestUserCapture (Date, Uid,
>>> User_Number) SELECT getdate(), @uid, @User
>>>
>>>
>>> INSERT TODAY..Flows_Log
>>> ( Flow_Number,
>>> Flow_Type,
>>> Flow_Usage,
>>> Transact_Type,
>>> Action_Type,
>>> Action_Date,
>>> User_People_Number,
>>> Date_Printed,
>>> Insight_Date,
>>> Date_Sent_To_Cats)
>>> SELECT Flow_Number,
>>> Flow_Type,
>>> Flow_Usage,
>>> Transact_Type,
>>> 'I',
>>> @Date,
>>> @User,
>>> null,
>>> null,
>>> null
>>> from inserted
>>>
>>>
>>> IF @@error <> 0
>>> begin
>>> rollback transaction
>>> raiserror 20001 'an error occurred while inserting
>>> into the Flows_Log for inserted Flows.
>>> All Transactions will be rolled back.'
>>> return
>>> end
>>> go
>>> IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
>>> PRINT '<<< CREATED TRIGGER dbo.Tr_flwsIns >>>'
>>> ELSE
>>> PRINT '<<< FAILED CREATING TRIGGER dbo.Tr_flwsIns
>>>>>> ' go
>>>
>>> Any ideas?
>>> Thanks
>>> Liezl


Liezl Posted on 2009-09-01 15:38:55.0Z
Sender: 2e05.4a9d3cfd.846930886@sybase.com
From: Liezl
Newsgroups: sybase.public.ase.general
Subject: Problem Persists: - RE: Issue with user_id() function returning wrong user now and then...
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4a9d400f.2ea0.1681692777@sybase.com>
References: <4a952733$1@forums-1-dub>
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 1 Sep 2009 08:38:55 -0700
X-Trace: forums-1-dub 1251819535 10.22.241.41 (1 Sep 2009 08:38:55 -0700)
X-Original-Trace: 1 Sep 2009 08:38:55 -0700, 10.22.241.41
Lines: 335
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28255
Article PK: 77498

This issue persists and the customer resonded on the
question below.

>>You mention that the selliot user had a problem some time
>>ago ...
>>Has the selliot's uid been added (or updated) in the Users
>>table since then?

NO
And NO duplicates

>>When the problem was occurring, did selliot's audit record
get >>set to 71 (unknown) or to some other number?

NO

>>You've also got 5 dozen users in sysusers who aren't in
your >>Users table, which I'm
>>assuming should generate an audit number = 71;
>>Do you consider 71 as an incorrect number?

NO - When the user is marked as 71 – it is the super user.

The customer still seem to return the wrong id's with the
user_id() function.

ANY further ideas?
L
> ... not sure what the problem is (at this point).
>
> You mention that the selliot user had a problem some time
> ago ... but it's hard to tell at this point if selliot's
> uid was added (or updated) in the Users table since then.
> When the problem was occurring, did selliot's audit
> record get set to 71 (unknown) or to some other number?
>
> You've also got 5 dozen users in sysusers who aren't in
> your Users table, which I'm assuming should generate an
> audit number = 71; do you consider 71 as an incorrect
> number?
>
> Since users can be dropped/(re)added to a database, and
> obtain a different uid after such an action, I'd have to
> question the process that keeps the Users table in sync.
> Could there be holes in this process that leads to
> unwanted 71's, or uid's not being inserted/updated
> properly if/when a user is dropped and/or (re)added?
>
> Liezl wrote:
> > Answers to the questions asked earlier
> > Thanks
> > Liezl
> >
> > select *
> > from sysusers s
> > where not exists(select u.uid
> > from Users u
> > where u.uid = s.uid)
> > and suid != -2
> > go
> > (user identities disguised)
> > suid uid gid name
> > environ
> > -99 1437 16395 user1 [NULL]
> > 40 222 16390 user2 [NULL]
> > 116 778 16390 sqr [NULL]
> > 487 506 16390 user4 [NULL]
> > 506 526 16390 user5 [NULL]
> > 523 542 16390 user6 [NULL]
> > 555 575 16390 user7 [NULL]
> > 568 588 16390 INSIGHT2 [NULL]
> > 575 594 16390 user8 [NULL]
> > 632 651 16390 user9 [NULL]
> > 637 656 16390 user10 [NULL]
> > 714 733 16390 user11 [NULL]
> > 730 749 0 user12 [NULL]
> > 739 758 16390 user13 [NULL]
> > 777 797 16390 logical
> > [NULL]
> > 811 831 16390 user14 [NULL]
> > 812 832 16390 NEWINSIGHT [NULL]
> > 856 877 16390 user15 [NULL]
> > 859 880 16390 user16 [NULL]
> > 890 913 0 user17 [NULL]
> > 891 1693 16391 user18 [NULL]
> > 892 915 0 user19 [NULL]
> > 893 916 16390 user20 [NULL]
> > 894 917 16390 user21 [NULL]
> > 895 918 16390 user22 [NULL]
> > 896 919 16390 user23 [NULL]
> > 897 920 16390 user24 [NULL]
> > 927 1589 16390 dummy1 [NULL]
> > 930 951 0 IMS_MAIN_maint
> > [NULL] 936 956 16390 user25 [NULL]
> > 940 1330 0 user26 [NULL]
> > 968 987 0 user27 [NULL]
> > 977 1590 16391 user28 [NULL]
> > 1049 1067 16390 user29 [NULL]
> > 1061 1260 16391 user30 [NULL]
> > 1211 1226 16390 user31 [NULL]
> > 1289 1307 16390 user32 [NULL]
> > 1324 1450 16390 system_security
> > [NULL] 1327 1345 16390 user33 [NULL]
> > 1377 1396 16391 user34 [NULL]
> > 1418 1435 16395 user35 [NULL]
> > 1420 1436 16395 user36 [NULL]
> > 1421 1438 16395 user37 [NULL]
> > 1422 1439 16395 user38 [NULL]
> > 1423 1440 16395 user39 [NULL]
> > 1431 1449 16390 user40 [NULL]
> > 1453 1472 16390 user41 [NULL]
> > 1474 1496 16390 user42 [NULL]
> > 1485 1507 16390 user43 [NULL]
> > 1505 1527 16390 user44 [NULL]
> > 1506 1528 16390 user45 [NULL]
> > 1513 1535 16390 user46 [NULL]
> > 1514 1536 16390 user47 [NULL]
> > 1523 1545 16390 user48 [NULL]
> > 1588 1613 0 user49 [NULL]
> > 1598 1623 16391 user50 [NULL]
> > 1599 1624 16391 user51 [NULL]
> > 1609 1667 16391 user52 [NULL]
> > 1619 1644 16391 user53 [NULL]
> > 1620 1645 16390 system_source [NULL]
> > 1624 1648 16391 user54 [NULL]
> > 1631 1655 16391 user55 [NULL]
> > 1635 1659 16390 user56 [NULL]
> > 1731 1757 16390 user57 [NULL]
> >
> > select user_name(71)
> > go
> >
> > NULL
> >
> > It has happened to the following user sometime ago:
> > select *
> > from sysusers
> > where name = 'selliott'
> > go
> >
> > suid uid gid name environ
> > 1577 1604 16390 selliott [NULL]
> >
> > L
> >
> >> I found a solved case @ sybase.com that mentions
> >> user_id()/user_name() returning wrong values in a
> 12.5.0.3 >> dataserver.
> >> The associated CR (389277) is mentioned as 'to be
> fixed' >> in ASE 12.5.4.
> >>
> >> There aren't any notes that describe any details of the
> >> case so I'm not sure under what situation the problem
> >> occurs.
> >>
> >> I'd suggest you open a case with Sybase TechSupport to
> see >> if they can verify that you've run into the same
> (or >> another?) issue.
> >>
> >> -------------------
> >>
> >> In the mean time, without access to the actual data I
> can >> only throw a few questions into the ring ...
> >>
> >> - have you verified that you have a valid mapping for
> >> every user_id() value in your Users table? what do you
> >> get from the following query:
> >>
> >>
> >
==========================
> >> use <dbname>
> >> go
> >>
> >> select *
> >> from sysusers s
> >> where not exists(select u.uid
> >> from Users u
> >> where u.uid = s.uid)
> >> and suid != -2
> >> go
> >>
> >
==========================
> >> - in the case of non-existing userid's, is your trigger
> >> inserting User_Number = 71? what does the following
> > query
> >> return?
> >>
> >>
> >
==========================
> >> use <dbname>
> >> go
> >>
> >> select user_name(71)
> >> go
> >>
> >
==========================
> >> - can you provide a sample (or two) problematic cases?
> in >> particular I'd be looking for the name of the
> database >> user (not their login name), and their
> sysusers info, eg: >>
> >>
> >
==========================
> >> use <dbname>
> >> go
> >>
> >> select *
> >> from sysusers
> >> where name = <database_user_name>
> >> go
> >>
> >
==========================
> >> - also provide your exact ASE version (select
> @@version) >>
> >>
> >>
> >>
> >> Liezl wrote:
> >>> We sometimes, very intermittently, get the wrong user
> >>> returned with the user_id() function on ASE 12.5.3
> when >>> used with a trigger.
> >>>
> >>> When a user connects and save information a trigger
> gets >>> executed that logs info for auditing purposes.
> >>>
> >>> The trigger selects the user_id() of the current user
> >>> logged in. It has been found that the user_id()
> returned >>> form the internal function, occasionally was
> the wrong >>> or an non-existing userid.
> >>>
> >>> IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
> >>> BEGIN
> >>> DROP TRIGGER dbo.Tr_flwsIns
> >>> IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
> >>> PRINT '<<< FAILED DROPPING TRIGGER
> >> dbo.Tr_flwsIns >>>> '
> >>> ELSE
> >>> PRINT '<<< DROPPED TRIGGER dbo.Tr_flwsIns >>>'
> >>> END
> >>> go
> >>>
> >>> CREATE TRIGGER dbo.Tr_flwsIns
> >>> ON dbo.DealInstrumentFlows
> >>> FOR insert
> >>> AS
> >>>
> >>
> /*********************************************************
> >>> ******************** * Trigger: Tr_flwsIns >>> *
> author: ? >>> * date: ?
> >>> * purpose: To insert into the TODAY..Flows_Log with
> the >>> Flows
> >>> * that where inserted and writes an
> Action_Type >>> of 'I' for inserted.
> >>> * It also inserts a date that the Flow is
> >>> written to the
> >>> * Flows_Log table.
> >>>
> >>
> **********************************************************
> >>> *******************/ >>> /*
> >>> ** Declare all variables
> >>> */
> >>>
> >>>
> >>> DECLARE @uid int
> >>> DECLARE @User int
> >>> DECLARE @Date datetime
> >>>
> >>> /* Determine the User performing the action */
> >>>
> >>>
> >>> SELECT @uid = user_id()
> >>>
> >>> SELECT @User = People_Number
> >>> FROM Users
> >>> WHERE uid = @uid
> >>>
> >>> SELECT @User = 71
> >>> WHERE @User is null
> >>>
> >>> SELECT @Date = GetDate()
> >>>
> >>> INSERT WORKSPACE..TestUserCapture (Date, Uid,
> >>> User_Number) SELECT getdate(), @uid, @User
> >>>
> >>>
> >>> INSERT TODAY..Flows_Log
> >>> ( Flow_Number,
> >>> Flow_Type,
> >>> Flow_Usage,
> >>> Transact_Type,
> >>> Action_Type,
> >>> Action_Date,
> >>> User_People_Number,
> >>> Date_Printed,
> >>> Insight_Date,
> >>> Date_Sent_To_Cats)
> >>> SELECT Flow_Number,
> >>> Flow_Type,
> >>> Flow_Usage,
> >>> Transact_Type,
> >>> 'I',
> >>> @Date,
> >>> @User,
> >>> null,
> >>> null,
> >>> null
> >>> from inserted
> >>>
> >>>
> >>> IF @@error <> 0
> >>> begin
> >>> rollback transaction
> >>> raiserror 20001 'an error occurred while
> inserting >>> into the Flows_Log for inserted Flows.
> >>> All Transactions will be rolled back.'
> >>> return
> >>> end
> >>> go
> >>> IF OBJECT_ID('dbo.Tr_flwsIns') IS NOT NULL
> >>> PRINT '<<< CREATED TRIGGER dbo.Tr_flwsIns >>>'
> >>> ELSE
> >>> PRINT '<<< FAILED CREATING TRIGGER dbo.Tr_flwsIns
> >>>>>> ' go
> >>>
> >>> Any ideas?
> >>> Thanks
> >>> Liezl


"Mark A. Parsons" <iron_horse Posted on 2009-09-01 16:10:49.0Z
From: "Mark A. Parsons" <iron_horse@no_spamola.compuserve.com>
User-Agent: Thunderbird 1.5.0.10 (Windows/20070221)
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: Problem Persists: - RE: Issue with user_id() function returning wrong user now and then...
References: <4a952733$1@forums-1-dub> <4a9d400f.2ea0.1681692777@sybase.com>
In-Reply-To: <4a9d400f.2ea0.1681692777@sybase.com>
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 8bit
X-Antivirus: avast! (VPS 090828-0, 08/28/2009), Outbound message
X-Antivirus-Status: Clean
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4a9d4789$1@forums-1-dub>
Date: 1 Sep 2009 09:10:49 -0700
X-Trace: forums-1-dub 1251821449 10.22.241.152 (1 Sep 2009 09:10:49 -0700)
X-Original-Trace: 1 Sep 2009 09:10:49 -0700, vip152.sybase.com
Lines: 51
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28256
Article PK: 77499


Liezl wrote:
>>> When the problem was occurring, did selliot's audit record
> get >>set to 71 (unknown) or to some other number?
>
> NO

Let's try this another way ... what are/were the values (expected vs actual)?

>>> You've also got 5 dozen users in sysusers who aren't in
> your >>Users table, which I'm
>>> assuming should generate an audit number = 71;
>>> Do you consider 71 as an incorrect number?
>
> NO - When the user is marked as 71 – it is the super user.

So what happens when one of those other 5 dozen users (listed in sysusers but not in Users) causes the trigger to fire?
According to the trigger logic I'd expect @User to be set to 71.

Are those 5 dozen users all designated as super users?

Is this a case of those 5 dozen users not having the rights to fire the trigger (eg, they are denied insert access on
the DealInstrumentFlows table)?

> The customer still seem to return the wrong id's with the
> user_id() function.

How is the customer determining this?

Can the customer log in as the problematic login, go to the database in question, run 'select user_id()' ... do they
receive the wrong user_id() value?

Given that a problem occurs with a specific login/user ... does this login/user always show the same wrong user_id()
value? or is this an intermittent issue?

When a specific login/user incurs a problem ... how does the problem manifest itself, ie, what values (@uid, @User) are
being generated? what values (@uid, @User) are expected?

> ANY further ideas?

From your posts it sounds like you're acting as an intermediary between this newsgroup and the user having the problem
(eg, it's not clear if you have direct access to the system and are seeing this problem first hand).

If this is the case then my other suggestions would be:

- have customer contact Sybase TechSuport

- have customer participate directly in this newsgroup discussion (preferably with a DBA that's familiar with the problem)

- have yourself (or a 3rd party) put in a position to directly access/investigate the problem