Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't insert '𡚸' to nvarchar2 #311

Open
zhangguojvn opened this issue Sep 20, 2023 · 3 comments
Open

Can't insert '𡚸' to nvarchar2 #311

zhangguojvn opened this issue Sep 20, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@zhangguojvn
Copy link

zhangguojvn commented Sep 20, 2023

Describe the bug

When inserting Chinese '𡚸' into a field of type nvarchar2, the result is '?'

To Reproduce

`
id := time.Now().Unix()

db.Exec("INSERT INTO "TESTUCHAR" ("ID","U_CHAR","VAR_CHAR") VALUES (:1,:2,:3)", id, "𡚸", "𡚸")

row := db.QueryRow("SELECT "U_CHAR" FROM "TESTUCHAR" WHERE ID = :1", id)

var result string

row.Scan(&result)

fmt.Print(result)

// output is : ?
`

Expected behavior

Insert normal characters

Error output

no error

Your oracle client version

21.7.0.0.0dbru

Your godror version

v0.34.0

Your go version

1.19.1

Your gcc version

gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)

Machine (please complete the following information):

  • OS: [centos in docker]
  • Architecture: [x86_64]
  • Version: [centos 8]
@sudarshan12s
Copy link
Collaborator

sudarshan12s commented Sep 20, 2023

Is it possible to confirm if you see same issue with 19c DB version.
I verified with cloud db (contrib/free.db , 19.21.0.1.0 ) and 21.3.0.0.0 , it works fine.

Also can you share the DB charset used (SELECT value AS db_charset FROM nls_database_parameters WHERE parameter = 'NLS_CHARACTERSET')

my setup has this.
AL32UTF8

@zhangguojvn
Copy link
Author

My database character set is ZHS16GBK.

I will

godror/stmt.go

Line 1160 in 91603ea

info.typ, info.natTyp = C.DPI_ORACLE_TYPE_VARCHAR, C.DPI_NATIVE_TYPE_BYTES
From

`

Info.typ, info.natTyp=C.DPI_ ORACLE_ TYPE_ VARCHAR, C.DPI_ NATIVE_ TYPE_ BYTES

`

Change to

`

Info.typ, info.natTyp=C.DPI_ ORACLE_ TYPE_ NVARCHAR, C.DPI_ NATIVE_ TYPE_ BYTES

`

And then it worked.

Perhaps I can create a new type such as "godror.Nchar" is dedicated to insert Nvarchar type data

@tgulacsi
Copy link
Contributor

tgulacsi commented Sep 20, 2023 via email

@tgulacsi tgulacsi added the enhancement New feature or request label Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants