I am trying to have a decode in a UDO.
The default decode syntax looks like this…
decode( )
This does not have any parameters to it. What is the number of parameters we can add in the decode. Can anyone give an example to it ?
Do we need to make any changes to the ora7EN.prm file ?
I don’t know about changes to the ora7EN.prm file, because I am currently using BO against MS SQL Server, but I do know about the decode syntax. Here is an example of using decode to print a full name for gender with a default of ‘Unknown’:
decode(gender,‘M’,‘Male’,‘F’,‘Female’,'Unknown)
This basically says, look at the gender column, if it is ‘M’ return ‘Male’, if it is ‘F’, return ‘Female’, else return ‘Unknown’. The last argument (the default) is optional. I don’t know if there is a limit to the number of cases you have, I have used several at a time.
I am trying to have a decode in a UDO.
The default decode syntax looks like this…
decode( )
This does not have any parameters to it. What is the number of parameters we can add in the decode.
Ashish, the functions for defining a UDO should work the same way as they do when you set up a new object in designer, and the syntax will vary based on your database platform. And, it appears that the reporter module doesn’t give users quite as free reign
Since I don’t use Oracle, I can’t tell you the exact syntax. (We don’t have a decode in Sybase, but use a CASE statement instead.)
However, I thought I’d seen this question asked once before, so I checked the listserv, and found the reply that comes below from Dave Rathbun, who is probably the most articulate contributor to this list. See his answer below, but first…
I tried the options suggested by Dave…but I keep getting the message… “Returns type incompatible with user object type” …which untrue… I have given the correct data type.
If i put double quotes for a alphanumeric ( " " ), then I get “bad character (not a function name?)”. what are these messages ?
I know decode syntax very well… this BO is diving me crazy…and making me forget my Oracle fundas.
If your Decode is truly :
decode( {Schooling\Schooling Degree}, ‘Associates’, 1, ‘Bachelors’, 2, ‘Masters’, 3, ‘Doctorate’, 4, 0)
You might want to consider making this a to_number function… i.e. to_number(decode( {Schooling\Schooling Degree}, ‘Associates’, ‘1’, ‘Bachelors’, ‘2’, ‘Masters’, ‘3’, ‘Doctorate’, ‘4’, ‘0’))
I tried the options suggested by Dave…but I keep getting the message… “Returns type incompatible with user object type” …which untrue… I have given the correct data
type.
If i put double quotes for a alphanumeric ( " " ), then I get “bad character (not a function name?)”.
what are these messages ?
I know decode syntax very well… this BO is diving me crazy…and making me forget my Oracle
fundas.
I tried it…but still getting the same message… what is your entry in the ORA7EN.prm file for decode ? There seems to be some problem with the single quotes ( ’ ). It says …wrong data type.
When I put double quotes ( " ), it does not give this error …instead says…“bad character(not a function name) ?”