Oracle Tip: Ignoring case and diacritic differences in an Oracle search.

February 1, 2010 by Reboot · Leave a Comment 

http://forums.oracle.com/forums/thread.jspa?threadID=14970

Instead of using the SQL UPPER and LOWER functions to perform case-insensitive queries, an alternative approach is to utilize the linguistic sort GENERIC_BASELETTER. GENERIC_BASELETTER groups all characters together based on their base letter values, this is achieved by ignoring their case and the diacritic differences.
Here is an example of a GENERIC_BASELETTER query.

ALTER SESSION SET NLS_COMP=ANSI;
ALTER SESSION SET NLS_SORT=GENERIC_BASELETTER;

SELECT * FROM PRODUCT
WHERE PRODUCT_NAME = database;

All other operators, such as LIKE, perform comparisons in binary mode only. i.e. they do not honor the NLS_SORT value. This has now been be enhanced in 10gR2.

See also:
Diacritics in like clause, Globalization support
http://dbaforums.org/oracle/index.php?showtopic=915

Diacritics
http://en.wikipedia.org/wiki/Diacritic

Oracle® Database Globalization Support Guide
http://download.oracle.com/docs/cd/B14117_01/server.101/b10749/ch5lingsort.htm#i1006463

Oracle NLS_LOWER
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions098.htm#i78373

Oracle Replace
http://www.psoug.org/reference/translate_replace.html

SELECT translate('árvíztűrőtükörfúrógép','áéíóöőúüű','aeiooouuu') without FROM dual

Oracle Tip: The decimal marker to a dot, and the thousands marker to a comma in to_number().

November 17, 2009 by Reboot · Leave a Comment 

to_number(t.yournumbercolumn,'9G999G999D99','NLS_NUMERIC_CHARACTERS='',.''')

See also:

Oracle NLS_NUMERIC_CHARACTERS
http://download.oracle.com/docs/cd/B28359_01/olap.111/b28126/dml_options072.htm

User Defined Aggregate Functions in Oracle 9i

February 17, 2009 by Reboot · Leave a Comment 

Just what I needed …