![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a databse that started life under ASA 5 and has been unloaded and reloaded in every version up to ASA 9.02. I have various fields with a default of CURRENT USER. These get filled with the name of the currently logged in user when a record is UPDATE-ed. However any new tables I add containing a field with default CURRENT USER does not get altered during and UPDATE. To do that I need to make it DEFAULT LAST USER. How come the old CURRENT USER fields carry on doing what they always did even though they look idential to a new CURRENT USER field (which now have to be LAST USER) when inspected in ISQL? If they have been magically altered to LAST USER fields should it not call them LAST USER in ISQL. If I make a field DEFAULT LAST USER will it get changed during Replication? The old CURRENT USER fields did not. A default of COMPUTE(current user) gets the name of the remote DBA put in during replication. I don't want this information changed by replication. |
#3
| ||||||
| ||||||
|
|
How come the old CURRENT USER fields carry on doing what they always did even though they look idential to a new CURRENT USER field (which now have to be LAST USER) when inspected in ISQL? If they have been magically altered to LAST USER fields should it not call them LAST USER in ISQL. |
|
If I make a field DEFAULT LAST USER will it get changed during Replication? |
|
The old CURRENT USER fields did not. |
|
... A default of COMPUTE(current user) gets the name of the remote DBA put in during replication. |
|
I don't want this information changed by replication. |
|
I have a databse that started life under ASA 5 and has been unloaded and reloaded in every version up to ASA 9.02. I have various fields with a default of CURRENT USER. These get filled with the name of the currently logged in user when a record is UPDATE-ed. However any new tables I add containing a field with default CURRENT USER does not get altered during and UPDATE. To do that I need to make it DEFAULT LAST USER. How come the old CURRENT USER fields carry on doing what they always did even though they look idential to a new CURRENT USER field (which now have to be LAST USER) when inspected in ISQL? If they have been magically altered to LAST USER fields should it not call them LAST USER in ISQL. If I make a field DEFAULT LAST USER will it get changed during Replication? The old CURRENT USER fields did not. A default of COMPUTE(current user) gets the name of the remote DBA put in during replication. I don't want this information changed by replication. |
#4
| |||
| |||
|
|
If I make a field DEFAULT LAST USER will it get changed during Replication? |
|
I have a databse that started life under ASA 5 and has been unloaded and reloaded in every version up to ASA 9.02. I have various fields with a default of CURRENT USER. These get filled with the name of the currently logged in user when a record is UPDATE-ed. However any new tables I add containing a field with default CURRENT USER does not get altered during and UPDATE. To do that I need to make it DEFAULT LAST USER. How come the old CURRENT USER fields carry on doing what they always did even though they look idential to a new CURRENT USER field (which now have to be LAST USER) when inspected in ISQL? If they have been magically altered to LAST USER fields should it not call them LAST USER in ISQL. If I make a field DEFAULT LAST USER will it get changed during Replication? The old CURRENT USER fields did not. A default of COMPUTE(current user) gets the name of the remote DBA put in during replication. I don't want this information changed by replication. |
#5
| |||
| |||
|
|
I'll answer one specific question in your post, since it appears that you've figured out that there are triggers on the tables that have DEFAULT CURRENT USER, but seem to be changed when you update the row. If I make a field DEFAULT LAST USER will it get changed during Replication? Possibly, and here's why, which will also explain why you have triggers on the tables in question and a DEFAULT CURRENT USER. Assume a table exists with the following schema at both the consolidated and remote : create table t1 ( pkey bigint default global autoincrement primary key, c1 integer, lu varchar(128) default last user ); Assume that the tables are in synch and both contain a single row with values ( 1, 1, 'DBA' ). Connect to the remote database as user 'CLIVE' and execute the following SQL : update t1 set c1 = 4 where pkey=1; commit; update t1 set c1 = 5 where pkey=1; commit; If you translate the transaction log right now for the remote database, you'll see the updates, and they'll look similar to : update t1 set c1=4, lu='CLIVE' where pkey=1; update t1 set c1=5 where pkey=1; Notice that the lu column did not change on the 2nd update (it was 'CLIVE', the new value was 'CLIVE'), so there is nothing in the transaction log to indicate this. These two update statements will be placed in the message when dbremote runs on the remote. Now, let's consider what happens when the consolidated picks up the message. Assume that user 'DBA' is used in the connection string for dbremote. The first update applies, and a specific value was given for the lu column, so the default never kicks in, and the value 'CLIVE' is used, as expected. Now, the second update occurs, but there's no value specified for the lu column, so the default on the consolidated kicks in. Since dbremote connects with user 'DBA', that's the value that is used for the lu column on the 2nd update. You get around this limitation by doing exactly what you did. Define the default to be CURRENT USER instead of LAST USER so that you still get the same effect on inserts. Now, define a before update trigger that only fires when dbremote is NOT running. create trigger bu_t1 before update on t1 referencing new as nr for each row begin if CURRENT REMOTE USER IS NULL then set nr.lu = CURRENT USER; end if; end; Now, when dbremote runs and there are two updates in a row from the same user, it does not get set to the user that is used by dbremote. -- Reg Domaratzki, Sybase iAnywhere Solutions Sybase Certified Professional - Sybase ASA Developer Version 8 Please reply only to the newsgroup iAnywhere Developer Community : http://www.ianywhere.com/developer iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals ASA Patches and EBFs : http://downloads.sybase.com/swx/sdmain.stm -> Choose SQL Anywhere Studio -> Set filter to "Display ALL platforms IN ALL MONTHS" "Clive Collie" <clive.doentdospam (AT) dillistone (DOT) com> wrote in message news:435644c3$1 (AT) forums-1-dub (DOT) .. I have a databse that started life under ASA 5 and has been unloaded and reloaded in every version up to ASA 9.02. I have various fields with a default of CURRENT USER. These get filled with the name of the currently logged in user when a record is UPDATE-ed. However any new tables I add containing a field with default CURRENT USER does not get altered during and UPDATE. To do that I need to make it DEFAULT LAST USER. How come the old CURRENT USER fields carry on doing what they always did even though they look idential to a new CURRENT USER field (which now have to be LAST USER) when inspected in ISQL? If they have been magically altered to LAST USER fields should it not call them LAST USER in ISQL. If I make a field DEFAULT LAST USER will it get changed during Replication? The old CURRENT USER fields did not. A default of COMPUTE(current user) gets the name of the remote DBA put in during replication. I don't want this information changed by replication. |
![]() |
| Thread Tools | |
| Display Modes | |
| |