I am working with a system (I am not the developer) that uses a half dozen databases, all on the same Sybase ASE 15.7 server.
The two important databases I need to access are TRANSACTIONS and CONFIGURATION. Both are updated in real-time, and only in real-time can I capture the data I want. Here's a super-simplified example of my trigger:
use TRANSACTIONS
go
CREATE TRIGGER myTrigger
ON UserLog
FOR INSERT
AS
BEGIN
--
-- do stuff here within the TRANSACTION database, no problems.
-- .......
-- Now, try to access the CONFIGURATION database, and boom, it fails
INSERT INTO myLog (somedata)
SELECT userData
FROM CONFIGURATION.dbo.UserConfiguration
WHERE ...blah...
END
My trigger always fails when a table is referenced from outside of the TRANSACTIONS database, not at any other time.
BTW, I'm logged in as systems admin when I create the trigger.
As noted in the Sybase documentation, triggers are part of transactions and if a serious error occurs in a trigger, the transaction is rolled back. This is exactly what I see occurring.
I suspect that the error is due to one of three possible causes:
- security grants for tables in the 'other' database some kind
- security-limitation configured at the time the database was built
- a Sybase restriction that cannot be overcome
Regarding #1, I've granted SELECT to PUBLIC and 'dbo' on the UserConfiguration table. DBO is the user who is creating the UserLog in TRANSACTIONS. But I'm not sure that my grant is applying correctly since every user is scoped to a specific database, not a global user.
Regarding #2, I can't figure out if there are any possible limitations that could be configured in, and not overcome.
Regarding #3, Sybase documentation states that my trigger SHOULD be able to reference tables in other databases.
Lastly, since I cannot see the error being raised or trap it, I have almost nothing to go on to tackle this problem. I don't want to insert my own records into the monitored table because it's not my table. I've hunted around for some kind of error log but I don't see any such thing. Is there one? I've researched trying to set the equivalent of TRY-CATCH blocks, blocks that would prevent an error from bubbling up, but Sybase appears to not have such controls.
Does anyone have any ideas how I might progress forward here?
My trigger is going to populate a table of my own in real-time and only needs to SELECT from the 'inserted' object, and tables in two databases.