By carson | Published:
August 2, 2006
If you ever need to find the next weekday from a given date in Oracle it turns out they have a built in function for doing just that. If you want the next Sunday from yesterday you would do:
SELECT NEXT_DAY(SYSDATE – 1, 'SUN') FROM dual;
Valid entries for the day are: SUN, MON, TUE, WED, THU, [...]
By carson | Published:
July 6, 2006
I pulled a large amount of SQL out of some existing code and wanted to have it formated nicely for me. I figured there had to be some type of pretty printer for SQL available outside of applications like TOAD. I have access to TOAD but it would have required a reboot so I figured [...]
By carson | Published:
April 29, 2006
A few days ago I made use of a couple Oracle built in functions and it made me happy I didn't have to write a stored proc or some type of mini-app to do it. I needed to parse a timestamp out of a field that was put there by a java program. The timestamp [...]
By carson | Published:
February 14, 2006
Today I needed to find a way to count the number of unique email domains in a table. I figured there was a way of getting the index of a string in another string and sure enough there is. This did the trick in Oracle:
SELECT count(1), SUBSTR(email, INSTR(email, '@', 1, 1)+1) FROM SOMETABLE GROUP BY [...]