Monday, November 26, 2012
I was executing a shell script file through the nohup command. while executing the file i got the ^M: not found error in unix command prompt.
Then i started searching why i am getting this error. after making several googling, i got to know that this is due to i created this shell script file in windows (eclipse) OS.
Normally when we create any file in windows and move/upload it to unix it append ^M in every line in the unix platform. it causes the error. now you need to remove these ^M character from the shell script to work it properly. You can do that i several ways
1. opening the script file VI editor and manually removing these extra charactors
2. using dos2unix command
Wednesday, November 7, 2012
Date and Time matching in Where clause in Oracle:
It is trick when you want to match date or date and time in where clause of you oracle sql query.
some time the original field may will be in date, time or some other field. and when you will put date type data with different format in where clause of you sql query it will mismatch and will not provide you the result you want.
You can avoid this kind of problem by using the to_date(date, format) in you where clause and the original field name as usual.
Below is an example:
where assoc_id = '6492349324'
and begin_date = TO_DATE('01-APR-2012', 'DD-MON-YYYY') --what ever will be the data type of begin_date
and end_date = TO_DATE('01-JUL-2012', 'DD-MON-YYYY') --the query will only match the date out of it
In the above query any date type data can be matched.