Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2013
    Posts
    2

    Unanswered: How to set application codepage using CLI

    I'm using DB2 CLI to insert data into a db2 database, which is created with codepage 1208(UTF-8). However, DBCLOB and GRAPHIC data cannot be inserted correctly.

    After investigating the problem carefully I found that, when CLI tracing is enabled, we can find the Application CODEPAGE is not correct"
    Application Codepage=1386, Database Codepage=1208

    I know that setting DB2CODEPAGE environment variable using db2set util can deal with this problem and I envoked the db2set command using ShellExecute in my program. However, I found that calling db2set will only take effect the next time my program starts hence my program must restart to reload the environment, which is unacceptable.

    So is there a way to set the application CODEPAGE using CLI, or other ways to overcome this problem?

  2. #2
    Join Date
    Apr 2012
    Posts
    1,034
    Provided Answers: 18
    The idea behind db2 registry variables is that they are typically permanently set.
    So it won't work to dynamically set them inside your program - because the db2 client initialisation will have read the registry variables once, before your code changes them.

    I believe that the Windows client derives the application code page from the Windows Regional Settings, which is the reason why on Windows developers use DB2CODEPAGE=1208.

    You might want to check exactly what's happening to your DBCLOB and GRAPHIC values - i.e. compare what is actually happening to what you expect to happen, and what DB2 is supposed to do for your combination of app-codepage and db-codepage.

  3. #3
    Join Date
    Oct 2013
    Posts
    2
    Quote Originally Posted by db2mor View Post
    The idea behind db2 registry variables is that they are typically permanently set.
    So it won't work to dynamically set them inside your program - because the db2 client initialisation will have read the registry variables once, before your code changes them.

    I believe that the Windows client derives the application code page from the Windows Regional Settings, which is the reason why on Windows developers use DB2CODEPAGE=1208.

    You might want to check exactly what's happening to your DBCLOB and GRAPHIC values - i.e. compare what is actually happening to what you expect to happen, and what DB2 is supposed to do for your combination of app-codepage and db-codepage.
    Thanks.
    But the data I'm inserting is purely composed of letters and spaces, There shouldn't be any encoding problems for all codesets.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •