you should change the function provided by oracle, you requirements are virtually the same so shouldnt be too hard to change it to meet your needs