![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
We have some local temporary tables with connetion specific information. We use this tables in triggers e.g. to update the record with the current user. Recently we have some problems with this. Question: Is it valid to use a local temporary table in a trigger? Thanks Arthur |
#3
| |||
| |||
|
|
Arthur Hefti schrieb: We have some local temporary tables with connetion specific information. We use this tables in triggers e.g. to update the record with the current user. Recently we have some problems with this. Question: Is it valid to use a local temporary table in a trigger? Thanks Arthur I think this will never work. A trigger gets fired when it matches the conditions you defined, no matter from which connection the action comes. Local temp tables are visible only for a specific connection. So if another connection performs an update it wont see the temp tables of other connections and will therefore fail if you try to reference such a table. I think you will see table not found errors. For the current user problem: why don't you use 'last user' as default value for the field you store your usernames? This automatically updates it with the user that inserted or updated the row. Check the documentation for the 'LAST USER' and 'CURRENT USER' special values! Tom |
#4
| |||
| |||
|
|
Arthur Hefti schrieb: We have some local temporary tables with connetion specific information. We use this tables in triggers e.g. to update the record with the current user. Recently we have some problems with this. Question: Is it valid to use a local temporary table in a trigger? Thanks Arthur I think this will never work. A trigger gets fired when it matches the conditions you defined, no matter from which connection the action comes. Local temp tables are visible only for a specific connection. So if another connection performs an update it wont see the temp tables of other connections and will therefore fail if you try to reference such a table. I think you will see table not found errors. For the current user problem: why don't you use 'last user' as default value for the field you store your usernames? This automatically updates it with the user that inserted or updated the row. Check the documentation for the 'LAST USER' and 'CURRENT USER' special values! Tom |
#5
| |||
| |||
|
|
Every connection has the same temptable definition. I can't use last user because the users are not database users. The application logs in with a default user. |
#6
| |||
| |||
|
|
We have some local temporary tables with connetion specific information. We use this tables in triggers e.g. to update the record with the current user. Recently we have some problems with this. |
|
Question: Is it valid to use a local temporary table in a trigger? |
#7
| |||
| |||
|
|
On Thu, 10 Sep 2009 11:34:15 +0200, Arthur Hefti <arthur (AT) catsoft (DOT) ch wrote: We have some local temporary tables with connetion specific information. We use this tables in triggers e.g. to update the record with the current user. Recently we have some problems with this. could you tell some details about these problems? Question: Is it valid to use a local temporary table in a trigger? we regularly use temporary tables from triggers, but we only read data from those. we have no problems so far. btw our scenario is the same as yours: we store connection specific data, like user, chosen GUI language, etc. triggers can access this table fine. |
#8
| |||
| |||
|
|
We create the tables when the application connects to the database -> CREATE TABLE #temptable (name long varchar, id integer) -> Insert connection specific information |
![]() |
| Thread Tools | |
| Display Modes | |
| |