I have a PL/SQL function with BOOLEAN in parameter:
function get_something(name in varchar2, ignore_notfound in boolean);
This function is a part of 3rd party tool, I cannot change this.
I would like to use this function inside a SELECT statement like this:
select get_something('NAME', TRUE) from dual;
This does not work, I get this exception:
ORA-00904: "TRUE": invalid identifier
As I understand it, keyword TRUE
is not recognized.
How can I make this work?
You can build a wrapper function like this:
then call:
It's up to you what the valid values of ignore_notfound are in your version, I have assumed 'TRUE' means TRUE and anything else means FALSE.
Compile this in your database and start using boolean statements in your querys.
note: the function get's a varchar2 param, so be sure to wrap any "strings" in your statement. It will return 1 for true and 0 for false;
The answer to this question simply put is: Don't use BOOLEAN with Oracle-- PL/SQL is dumb and it doesn't work. Use another data type to run your process.
A note to SSRS report developers with Oracle datasource: You can use BOOLEAN parameters, but be careful how you implement. Oracle PL/SQL does not play nicely with BOOLEAN, but you can use the BOOLEAN value in the Tablix Filter if the data resides in your dataset. This really tripped me up, because I have used BOOLEAN parameter with Oracle data source. But in that instance I was filtering against Tablix data, not SQL query.
If the data is NOT in your SSRS Dataset Fields, you can rewrite the SQL something like this using an INTEGER parameter:
__
If the data is in your SSRS Dataset Fields, you can use a tablix filter with a BOOLEAN parameter:
__
From documentation:
You will need to make a wrapper function that takes an
SQL
datatype and use it instead.PL/SQL is complaining that TRUE is not a valid identifier, or variable. Set up a local variable, set it to TRUE, and pass it into the get_something function.