Muhammad Usman
Muhammad Usman

Reputation: 10148

Arabic characters always null in oracledb nodejs update query

i am running query in oracle db with nodejs as

await executeQuery(connection, updateStatusQueryFail, {
    status: "unmatched",
    iban: iban,
    NID_MISMATCH: mismatches['nid'],
    PASSPORT_MISMATCH: mismatches['passport_number'],
    PHONE_MISMATCH: mismatches['phone'],
  });

mismatches.passport_number has arabic values in it and the above query is mapped to

const updateStatusQueryFail = `UPDATE DIGX_CZ_CBL_FCMS_ACCOUNT_LIST
 SET STATE = :status,
 NID_MISMATCH = :NID_MISMATCH,
 PASSPORT_MISMATCH = :PASSPORT_MISMATCH,
 PHONE_MISMATCH = :PHONE_MISMATCH,
 UPDATED_AT= SYSDATE
 WHERE IBAN = :iban`; 

the weird part is, it does not work when I try it like this

await executeQuery(connection, updateStatusQueryFail, {
    status: "unmatched",
    iban: iban,
    NID_MISMATCH: mismatches['nid'],
    PASSPORT_MISMATCH: mismatches['passport_number'],
    PHONE_MISMATCH: mismatches['phone'],
  });

but works when I try it like

await executeQuery(connection, updateStatusQueryFail, {
    status: "unmatched",
    iban: iban,
    NID_MISMATCH: mismatches['nid'],
    PASSPORT_MISMATCH:  'يجب أن يحتوي النص رقم جواز السفر على 8 حروفٍ/حرفًا بالظبط'
    PHONE_MISMATCH: mismatches['phone'],
  });

I am using node 20 vesion, with oracledb driver. Any help would be highly appreciated. Oh yeah no error is thrown.

Almost spent 4-6 hours already.

Upvotes: -1

Views: 78

Answers (1)

Hoppix
Hoppix

Reputation: 660

Check the oracledb configuration in your Node.js application. You may need to set the oracledb.fetchAsString property to handle strings with special characters. And also, check that the NLS_LANG environment variable is set correctly.

oracledb.fetchAsString = [oracledb.CLOB];
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8

lastly, check that your Oracle database and Node.js application are using the same character set and collation. Arabic characters may require a specific character set to be handled correctly.

Upvotes: 0

Related Questions