Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 89275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:41:28+00:00 2026-05-10T22:41:28+00:00

I use the following statement prepared and bound in ODBC: SELECT (CASE profile WHEN

  • 0

I use the following statement prepared and bound in ODBC:

SELECT (CASE profile WHEN ? THEN 1 ELSE 2 END) AS profile_order  FROM engine_properties; 

Executed in an ODBC 3.0 connection to an Oracle 10g database in AL32UTF8 charset, even after binding to a wchar_t string using SQLBindParameter(SQL_C_WCHAR), it still gives the error ORA-12704: character set mismatch.

Why? I’m binding as wchar. Shouldn’t a wchar be considered an NCHAR?

If I change the parameter to wrap it with TO_NCHAR() then the query works without error. However since these queries are used for multiple database backends, I don’t want to add TO_NCHAR just on Oracle text bindings. Is there something that I am missing? Another way to solve this without the TO_NCHAR hammer?

I haven’t been able to find anything relevant via searches or in the manuals.

More details…

— error

SELECT (CASE profile WHEN          '_default'  THEN 1 ELSE 2 END) AS profile_order FROM engine_properties; 

— ok

SELECT (CASE profile WHEN TO_NCHAR('_default') THEN 1 ELSE 2 END) AS profile_order FROM engine_properties; 
 SQL> describe engine_properties;  Name                                      Null?    Type  ----------------------------------------- -------- ----------------------------  EID                                       NOT NULL NVARCHAR2(22)  LID                                       NOT NULL NUMBER(11)  PROFILE                                   NOT NULL NVARCHAR2(32)  PKEY                                      NOT NULL NVARCHAR2(50)  VALUE                                     NOT NULL NVARCHAR2(64)  READONLY                                  NOT NULL NUMBER(5) 

This version without TO_NCHAR works fine in SQL Server and PostgreSQL (via ODBC) and SQLite (direct). However in Oracle it returns ‘ORA-12704: character set mismatch’.

SQLPrepare(SELECT (CASE profile WHEN ? THEN 1 ELSE 2 END) AS profile_order      FROM engine_properties;) = SQL_SUCCESS SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR,      SQL_VARCHAR, 32, 0, '_default', 18, 16) = SQL_SUCCESS SQLExecute() = SQL_ERROR SQLGetDiagRec(1) = SQL_SUCCESS [SQLSTATE: HY000, NATIVE: 12704, MESSAGE: [Oracle][ODBC]     [Ora]ORA-12704: character set mismatch] SQLGetDiagRec(2) = SQL_NO_DATA 

If I do use TO_NCHAR, it’s okay (but won’t work in SQL Server, Postgres, SQLite, etc).

SQLPrepare(SELECT (CASE profile WHEN TO_NCHAR(?) THEN 1 ELSE 2 END) AS profile_order     FROM engine_properties;) = SQL_SUCCESS SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR,      SQL_VARCHAR, 32, 0, '_default', 18, 16) = SQL_SUCCESS SQLExecute() = SQL_SUCCESS SQLNumResultCols() = SQL_SUCCESS (count = 1) SQLFetch() = SQL_SUCCESS 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:41:28+00:00Added an answer on May 10, 2026 at 10:41 pm

    If the Oracle database character set is AL32UTF8, why are the columns defined as NVARCHAR2? That means that you want those columns encoded using the national character set (normally AL16UTF16, but that may be different on your database). Unless you are primarily storing Asian language data (or other data that requires 3 bytes of storage in AL32UTF8), it is relatively uncommon to create NVARCHAR2 columns in an Oracle database when the database character set supports Unicode.

    In general, you are far better served sticking with the database character set (CHAR and VARCHAR2 columns) rather than trying to work with the national character set (NCHAR and NVARCHAR2 columns) because there are far fewer hoops that need to be jumped through on the development/ configuration side of things. Since you aren’t increasing the set of characters you can encode by choosing NVARCHAR2 data types, I’ll wager that you’d be happier with VARCHAR2 data types.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 71k
  • Answers 71k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I think version 1.8 of the Zend Framework is going… May 11, 2026 at 1:28 pm
  • added an answer By dynamically linking with /MD, you are exposed to system… May 11, 2026 at 1:28 pm
  • added an answer The documentation for re.findall: findall(pattern, string, flags=0) Return a list… May 11, 2026 at 1:28 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.