cancel
Showing results for 
Search instead for 
Did you mean: 

Create a norwegian database

ovehalseth-1
Explorer
1,069

We had a database created like this: CREATE DATABASE 'norwegian.db' COLLATION '819NOR' NCHAR COLLATION 'UCA';

But got problems when trying to store characters outside that collation.

So we reloaded the database to: CREATE DATABASE 'norwegian.db' COLLATION 'UTF8BIN' NCHAR COLLATION 'UTF8BIN';

But now we have problem with sorting and comparison. Well sorting we solved with: set option sort_collation='48' or set option sort_collation='UCA(locale=nob)' (not sure if they are equal, or wich to prefere?)

But when comparing: Name like 'Øyv%' or select if 'æ' = lower('Æ') then 'true' else 'false' end if returns false

How do we create a database that will store in UTF8 but sort and compare in norwegian?

Accepted Solutions (0)

Answers (2)

Answers (2)

bjanker77
Participant

Hi.

Try to use 1252NOR instead. We always use that in our applications, and it has never created any issues for us.

br,

Bjarne Anker Maritech Systems AS

VolkerBarth
Contributor
0 Kudos

Just two questions/remarks:

  • Do you use CHAR or NCHAR data types for those international texts? Because by default NCHAR data will use the UCA collation, which should work fine in your original database. However, if you are using CHAR data types and want to store international data, the default single byte character sets won't allow more than 256 char, obviously. If that limit is critical, you need to use UCA there, as well.

  • UTF8BIN is a multi-byte character set with binary sorting, so it by design treats each characters with and without accents or case as different. That is apparently not your goal.

If you want multi-byte characters both with CHAR and NCHAR, I guess the following should do:

CREATE DATABASE 'norwegian.db' COLLATION 'UCA(locale=no;case=ignore;accent=ignore)' NCHAR COLLATION 'UCA(locale=no;case=ignore;accent=ignore)';

I can't tell whether the "collation tailoring options" do fit and whether Norwegian has particular sorting variants like German or Swedish (via sorttype=phonebook), so you might adjust that.

Note that using the UCA collation by default uses UTF-8 as encoding.

Just to add: Whether you need to distinguish between Bokmål and Nynorsk is fully out of my scope... 🙂

ovehalseth-1
Explorer
0 Kudos

Looks promising! Tested: set temporary option sort_collation='UCA(locale=nob;case=ignore;accent=ignore)';

And got correct sorting, so will schedule a conversion of the database and see if it helps 🙂

Oh, and I did not get locale=no to work, but locale=nob did work. I guess it stands for Norwegian Bokmål. But then I would expect that locale=non for Nynorsk should work too, but it did not.

But it does not matter as both sort the same.

VolkerBarth
Contributor
0 Kudos

Note, you can also "test collation sorting" without having to create a new database by using the COMPARE function and specifying the desired collation, see here.

That does also help to compare results of different collation tailoring options side-by-side.