![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
This is interesting. Say I have a package with a function in it. The function is local to that package only and is not called from the outside. Now, I have a line like this: v_select := 'SELECT col1, col2, GET_PRICE(col3) FROM products'; open p_output for v_select; That fails. But, if I create the function by itself, as a normal function, then it works fine. Why is this? Because the function is private the the package. You would see that if you |
#3
| |||
| |||
|
|
"Mtek" <mtek (AT) mtekusa (DOT) com> wrote in message news:c468a5f4-da3f-4027-99db-1f528bbf27d7 (AT) m40g2000yqh (DOT) googlegroups.com... This is interesting. Say I have a package with a function in it. The function is local to that package only and is not called from the outside. |
|
Now, I have a line like this: v_select := 'SELECT col1, col2, GET_PRICE(col3) FROM products'; open p_output for v_select; That fails. But, if I create the function by itself, as a normal function, then it works fine. Why is this? Because the function is private the the package. You would see that if you didn't quote the cursor. If the function is public in the package then you can do cursor foo is SELECT col1, col2, my_package.GET_PRICE(col3) get_price FROM products; |
#4
| |||
| |||
|
|
This is interesting. Say I have a package with a function in it. The function is local to that package only and is not called from the outside. Now, I have a line like this: v_select := 'SELECT col1, col2, GET_PRICE(col3) FROM products'; open p_output for v_select; That fails. But, if I create the function by itself, as a normal function, then it works fine. Why is this? I (have to) guess that you call the statement v_select := ... from |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
Robert Klemme (shortcutter (AT) googlemail (DOT) com) wrote: : On 20.02.2009 22:03, gym dot scuba dot kennedy at gmail wrote: : > "Mtek" <mtek (AT) mtekusa (DOT) com> wrote in message : > news:c468a5f4-da3f-4027-99db-1f528bbf27d7 (AT) m40g2000yqh (DOT) googlegroups.com... : >> This is interesting. Say I have a package with a function in it. The : >> function is local to that package only and is not called from the : >> outside. : Here you have provided the explanation yourself. Hardly. After all, the sql statement has access to variables that are private but within scope. |
#7
| |||
| |||
|
#8
| |||
| |||
|
|
Robert Klemme (shortcutter (AT) googlemail (DOT) com) wrote: : On 21.02.2009 18:03, Malcolm Dew-Jones wrote: : > Robert Klemme (shortcutter (AT) googlemail (DOT) com) wrote: : > : On 20.02.2009 22:03, gym dot scuba dot kennedy at gmail wrote: : > : > "Mtek" <mtek (AT) mtekusa (DOT) com> wrote in message : > : news:c468a5f4-da3f-4027-99db-1f528bbf27d7 (AT) m40g2000yqh (DOT) googlegroups.com... : > : >> This is interesting. Say I have a package with a function in it. The : > : >> function is local to that package only and is not called from the : > : >> outside. : : > : Here you have provided the explanation yourself. : : > Hardly. After all, the sql statement has access to variables that are : > private but within scope. : I am not sure what you intend to say with this. The OP wrote about a : package private function which he attempted to call from outside of the : package. I do not see how code outside of a package can have access to : anything which is private to the package - be it a function, a variable : or something else. In fact, I would rather consider it a bug if : something private could be accessed from the outside. No, he said the function "is not called from the outside." I don't see any way to interpret that except that the line he mentioned must be built and used within his package. Something like package XXX function GET_PRICE( p number ) is begin return p*10; end procedure do_something is v_select varchar2(4000); begin v_select := 'SELECT col1, col2, GET_PRICE(col3) FROM products'; open p_output for v_select; ...etc... end; end package XXX; I noted that the sql statement he is building would have access to any variables that are in scope within the do_something procedure - so (rhetorical question) why does the sql not have access to the function that appears to be within scope? From a logical point of view any statement or expression at that point in the code should have access to the function. If the function was used at that point in the code in any other type of statement then it would be in scope and visible. If he was using a local variable instead of a function then the variable would be in scope and visible for any type of statement even an SQL statement. The fact that the *function* is not in scope, even though in virtually any other language a construct such as that would be in scope, and indeed even though pl/sql itself is able to recognize some items (local variables) as being in scope, and indeed even though pl/sql itself has at least one work around for another kind of object (types) so as to make it _appear_ to be in scope even when it isn't - the fact that the function is not in scope is a limitation of the implementation of the pl/sql language. $0.10 I think the piece that he is missing is that sql statements are executed by |
#9
| |||
| |||
|
#10
| ||||
| ||||
|
|
Robert Klemme (shortcut... (AT) googlemail (DOT) com) wrote: : On 21.02.2009 18:03, Malcolm Dew-Jones wrote: : > Robert Klemme (shortcut... (AT) googlemail (DOT) com) wrote: : > : On 20.02.2009 22:03, gym dot scuba dot kennedy at gmail wrote: : > : > "Mtek" <m... (AT) mtekusa (DOT) com> wrote in message : > : >news:c468a5f4-da3f-4027-99db-1f528bbf27d7 (AT) m40g2000yqh (DOT) googlegroups..com... : > : >> This is interesting. *Say I have a package with a function in it. *The : > : >> function is local to that package only and is not called from the : > : >> outside. : : > : Here you have provided the explanation yourself. : : > Hardly. *After all, the sql statement has access to variables that are : > private but within scope. : I am not sure what you intend to say with this. *The OP wrote about a : package private function which he attempted to call from outside of the : package. *I do not see how code outside of a package can have access to : anything which is private to the package - be it a function, a variable : or something else. *In fact, I would rather consider it a bug if : something private could be accessed from the outside. No, he said the function "is not called from the outside." *I don't see any way to interpret that except that the line he mentioned must be built and used within his package. |
|
I noted that the sql statement he is building would have access to any variables that are in scope within the do_something procedure - so |
|
(rhetorical question) why does the sql not have access to the function that appears to be within scope? From a logical point of view any statement or expression at that point in the code should have access to the function. *If the function was used at that point in the code in any other type of statement then it would be in scope and visible. *If he was using a local variable instead of a function then the variable would be in scope and visible for any type of statement even an SQL statement. |
|
The fact that the *function* is not in scope, even though in virtually any other language a construct such as that would be in scope, and indeed even though pl/sql itself is able to recognize some items (local variables) * as being in scope, and indeed even though pl/sql itself has at least one work around for another kind of object (types) so as to make it _appear_ to be in scope even when it isn't - the fact that the function is not in scope is a limitation of the implementation of the pl/sql language. |
![]() |
| Thread Tools | |
| Display Modes | |
| |