Tuesday, November 1, 2016

Print Tick Mark in Oracle SQL Query [Solved]

Issue: Client wanted a column to have a condition in a way that if it is a 'Y' flag then a tick mark should be shown. This was a flat file report.

Resolution: You can't exactly call this a resolution but here is what you can do, As a workaround we searched for a character that matched, we found that in the Western Europe (DOS/OS2-437/US) character set. The 251th character is a symbol that resembles a tick mark.

SELECT CHR(251) FROM DUAL 

You will have to check in a DOS/OS2-437/US characterset database to find an exact match. This character will not be available in the most commonly used WE8ISO8859P1 and AL32UTF8 character sets.

Since our report was based on a case condition we wrote it inside a case statement,

SELECT CASE WHEN 1=1 THEN '√' ELSE NULL END

Another alternative is to use the symbol in query below,

SELECT '✓' FROM DUAL

We wrote the case statement and output data to flat file. The change reflected in Flat File as well. This is a work around, make sure the workaround is properly committed to client to avoid last minute issues.


Note: You will not be able to insert the data to a table with character set other than DOS/OS2-437/US.

Kindly comment if you have any other work-around which would work better. 




No comments:

Post a Comment