1

I created the following table with one text column:

create table table1 (
  col1 varchar2(20)
);

Then I inserted one Polish letter to it:

insert into table1 values ('ą')

How can I obtain the number of characters in this string? It should be 1, but all functions that I know return other results: LENGTH(COL1) -> 2, LENGTHC(COL1) -> 2, LENGTH2(COL1) -> 2, LENGTH4(COL1) -> 2, LENGTHB(COL1) -> 6.

The SELECT * FROM NLS_DATABASE_PARAMETERS; returns:

PARAMETER              VALUE
---------------------------------
NLS_RDBMS_VERSION      18.0.0.0.0
NLS_NCHAR_CONV_EXCP    FALSE
NLS_LENGTH_SEMANTICS   BYTE
NLS_COMP               BINARY
NLS_SORT               BINARY
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_CHARACTERSET       AL32UTF8
NLS_ISO_CURRENCY       AMERICA
NLS_TERRITORY          AMERICA
NLS_LANGUAGE           AMERICAN
...                    ...

You can check it on: dbfiddle.uk.

4
  • 1
    select dump(col1) from table1 shows that the character is stored in six bytes. I can't reproduce that either on my own computer or on livesql; that's a question for dbfiddle. Did you try it on your own computer, or only on dbfiddle? Commented Nov 13, 2020 at 14:27
  • Seems like an Oracle 18.4 bug (which dbfiddle is using). It works for me on 12.1, 12.2 18.7, 18.10 and 19.8 Commented Nov 13, 2020 at 14:28
  • I was testing it only on dbfiddle. Thank you - this solves the problem. Commented Nov 13, 2020 at 14:29
  • @a_horse_with_no_name - to me it seems more likely that it's a dbfiddle bug (perhaps in how it reads characters from its web interface, or whatnot) rather than an Oracle bug, regardless of version. Commented Nov 13, 2020 at 14:30

1 Answer 1

2

It is most likely a bug with the version of Oracle you are running the query on or an issue with the character being encoded on the web server.

I have almost all of the same NLS parameters on my system except I am on Oracle 19 instead of 18.

toad screenshot

Even on livesql.oracle.com it returns the results as you would expect but again, that database is on Oracle 19.

livesql screenshot

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Now I am testing SQL queries on livesql.oracle.com and they works properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.