Search code examples
c#entity-frameworkdb2db2-400db2-connect

Changing Collation order with IBM.Data.DB2-driver to DB2 for IBM i


We have hundreds of web apps that need to support localization. Our back end is a combination of Asp.net Web API with legacy DB2 for IBM i.

To connect from C# to DB2 we use IBM Data Server Client 10.5 FP5 package -> managed .Net drivers.

With native .Net Drivers from Client Acccess for System i-package there was support to pass additional keywords (SortSequence/Language) along with ConnectionString.

To have this similar functionality with IBM.DATA.DB2-drivers feature request is made, but seems that there are no business justifications for it as it does not seem to progress at all.

https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=56495

Does anyone know any other method to pass culture info choices along with the rest of the db connection info to DB2 for IBM i ? (job desription, db2dsdriver.cfg, db2cli.ini)

Br, Kappas


Solution

  • I didn't find neither though it seems all other driver would support the collation parameters, including Java Toolbox.

    The workaround I use is to set the user profile used for the connection pool according to the language specifications for the sort order.

    In our case, for french canadian, the following USRPRF values are SRTSEQ(*LANGIDSHR) LANG(FRC)

    *LANGIDSHR means case insensitive, accent insensitive in the DB world. The default for this parm is *HEX and normally set thru the *SYSVAL QSRTSEQ. You may also want the change the SYSVAL for *LANGIDSHR but I didn't really experiment the effects on legacy applications.

    You can't play with the collation programmatically, but still can create as many users you need different collation and switch between them.

    BIG WARNING: If you created index to speedup your access, you have to be aware that the index creation reacts to the actual collation of the index Creator user. If the DBA user profile says SRTSEQ *HEX (the default), you index will be created as SRTSEQ *HEX and won't be usable by connections made in SRTSEQ *LANGIDSHR. We took a very long time to figure out why our index were sometimes used, sometimes not. We ended-up creating our index in both *HEX and *LANGIDSHR during a transition period until everyone is set to *LANGIDSHR. Sort Seq of any logical file, index or view can easily be found in DSPFD, searching for SRTSEQ attribute.