Tuesday, June 7, 2011

Oracle escaping the single quote(') in a select

This query will fail when doing a select statement:

select * from table_name where field='it's friday today';



To escape the single quote (') you need to add in another single quote (''):

select * from table_name where field='it''s friday today';

Wednesday, June 1, 2011

": No such file or directory" Error on Linux

If you have ever encounter these errors on a Linux server: ": No such file or directory" or ": command not found" when attempting to run a script it may actually be a problem with the format of the file i.e. it may be a dos file. You can convert the file from dos to Unix using the following command:



$ dos2unix filename

N.B. On Solaris you may get a different error i.e. "^M: does not exist". You can use the same functionality to convert the file to Unix format.