Bypass package function with name conflict [message #439601] |
Mon, 18 January 2010 10:42  |
brlav35
Messages: 4 Registered: September 2009 Location: QUEBEC
|
Junior Member |
|
|
Hello,
I have to maintain a package having 2 functions named: true and false. As you're seeing these two functions are named with the same name of TRUE and FALSE boolean values.
It was compiling successfully until I needed to add a function that return a real boolean. When I do a RETURN {TRUE|FALSE}, the compilation fails with the message:
PLS-00382: expression is of wrong type
Because the pl/sql boolean that I try to return takes one of the functions pkg.true or pkg.false, that is not of boolean type but char.
How to tell oracle that wanted true and false are these of PL/SQL rather than the local functions?
Thanks
Bruno
|
|
|
|
|
Re: Bypass package function with name conflict [message #439700 is a reply to message #439603] |
Tue, 19 January 2010 02:45   |
 |
Maaher
Messages: 7065 Registered: December 2001
|
Senior Member |
|
|
The concept behind the example Michel posted is name resolution. Here's what the documentation has to say about this:
The Oracle documentationDuring compilation, the PL/SQL compiler determines which objects are associated with each name in a PL/SQL subprogram. A name might refer to a local variable, a table, a package, a subprogram, a schema, and so on. When a subprogram is recompiled, that association might change if objects were created or deleted.
A declaration or definition in an inner scope can hide another in an outer scope.
... More can be found here. Especially the part about capture is interesting.
And although Oracle can accept the usage of reserved words for qualifiers, I think BlackSwan is right. Don't use a reserved word as a name of your own object, parameter, ... .
MHE
|
|
|
Re: Bypass package function with name conflict [message #439855 is a reply to message #439700] |
Tue, 19 January 2010 14:08   |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
I feel very strongly about this - get rid of those true & false function names - they should never have made it into the code in the first place. As your code gets bigger & more complex, you'll run into more & more issues by not respecting reserved words. Code formatters stop working properly, and in some case you won't be lucky enough to even see an error. Just because you can do a bad thing, it's never an excuse to do so...
SQL> create table bad_table ("null" varchar2(10), "USER" varchar2(10), "SYSDATE" varchar2(10));
Table created.
SQL> insert into bad_table values ('xxx', 'yyy', 'zzz');
1 row created.
SQL> select null, user, sysdate from bad_table;
N USER SYSDATE
- ------------------------------ ---------
SCOTT 19-JAN-10
SQL>
http://awads.net/wp/2007/01/10/what-does-reserved-y-really-mean/
[Updated on: Tue, 19 January 2010 14:09] Report message to a moderator
|
|
|
|
|
|
|