When I wrote the cvtDate() SQL function in SQL, the documentation gave me the impression that I could define so called overloaded functions. Basically these different functions that have the same name, but different parameter types or parameter count.
So I initially created two of them:
cvtDate( inDate dec(8,0), fmt varchar(4))
cvtDate( inDate dec(8,0) )
Not too different at all. Apparently you can't have optional parameter so the practice is to define multiple functions, that is, use Overloading.
After the usual development cycle, I decided I wanted to also support converting dates stored in character fields, to true dates. After all, it would be cool to process the date values in an outfile from DSPOBJD or others by wrapping them in cvtDate().
So I defined yet another function as follows:
cvtDate( inDate varchar(128) , fmt varchar(16) )
cvtDate( inDate varchar(128) )
This would mean I could specify one function, CVTDATE() and not worry if the date in the file was stored in numeric or character (so long as I knew the format in which it was stored).
Sadly, it won't let me compile these second set of function "Function CVTDATE already exists."
I am not certain if it is something I'm doing or if this is a known limitation or a bug, either way, it it basically means that I have to define yet another function, perhaps named charDate() that will do what I need it to.