on 2024 Aug 28 6:25 AM
I have such a table with bidirectional synchronisation (using shadow tables) (MLSRV17.exe & DBMLSYNC.exe)
create or replace table mytable( col1 varchar(10), col2 int, primary key ("col1") );I have problem when executing such a statement on Cons.:
update mytable set col1 = 'value1', col2 = 10 where col1 = 'Value1';
The row was already existing in both databases (with col1 = 'Value1', the above transaction will be sent to the cons. in this way
insert into mytable on existing update values ('value1', 10);
which will in turn be executed in this way:
update mytable set col1 = 'value1', col2 = 10 where col1 = 'Value1';
At the end I get the following error: SQL statement failed: (-780) Cannot update primary key for table 'mytable' involved in a publication
The question is, how can I enforce dbmlsync to work case insensitive?
Any attempt to update a primary key of a table, on a remote, that is in a publication will report the error cited. You did not see this on the consolidated as it does not have a publication with that table. And note that primary key will be updated on the consolidated as as long as the consolidated DBMS permits it,
The issue you are tripping over has nothing to do with case sensitivity in MobiLink but rather the behaviour of char type values in SQL Anywhere. SQL Anywhere stores the character string supplied regardless of case sensitivity. So, if you supply value, it stores value. If you then update to VALUE, the column is changed to VALUE.
In your example, the update sets col1 to 'value1' resulting in a change in the primary key value from 'Value1' to 'value1'. That change must go to the remote to be applied in order to keep the databases in sync but it cannot be applied because the column is a primary key.
If this was an accidental UPDATE that included the the primary key column, you could perform another update the returns the primary key column to the same value as on the remote. This will result in the update as not affecting the primary key. Otherwise, I would want to look for a way to prevent such updates.
I have a couple of best practices:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried:
update mytable set col1 = 'value1', col2 = 10 where col1 = 'Value1' and lcase(col1) <> lcase('Value1');
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
10 | |
10 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.