cancel
Showing results for 
Search instead for 
Did you mean: 

Is Mobilink (dbmlsync) Case sensitive?

Baron
Participant
0 Kudos
583

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?

Accepted Solutions (0)

Answers (2)

Answers (2)

chris_keating
Product and Topic Expert
Product and Topic Expert

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:

  • Avoid using char types as a primary key.  
  • Avoid updating primary keys i.e., never set a PK column in a UPDATE, even outside of a MobiLink context. 
  • Never update a primary key for any table that is involved in synchronization.
timcheshire
Explorer
0 Kudos

Have you tried:

update mytable set col1 = 'value1', col2 = 10 where col1 = 'Value1' and lcase(col1) <> lcase('Value1');

Baron
Participant
0 Kudos

I can't do this:

1- On the Cons. it is the user who executes the update statement, and the database allows him to do so, I can only avoid this from happening via a trigger.

2- On the Remote it is the dbmlsync.exe who executes the update statement, so I can do nothing.