If wishes were horses
Stephan Uzzell, August 21, 2007 - 10:12 pm UTC
I agree completely, Tom, unfortunately, it is out of my hands. The actual function is going to vary from install to install (based on tax laws). Generally, it is one thing, but there's no guarantee to that effect.
Given the way it is stored, do you see any way to call it?
As always, thanks.
August 22, 2007 - 1:30 pm UTC
how do you know what to replace in there? If it is always "I supply a single input, it gives me a single output" then you should be storing:
begin :x := f( :y, 1,2,3,4 ); end;
then you can select that out, and execute it. As is,
execute immediate l_str using OUT p_return, IN p.id;
just bear in mind, you'll be parsing this way more than you should, I still think this is an INSTALL TIME THING, at the time you INSTALL, you hard code the right function in there, done, no worries.
How about dynamic SQL?
Pedro M. Guerra, August 22, 2007 - 6:36 am UTC
Stephan,
If I understood your question, you need a way to call a function from SQL instructions, and that function name (anda parameters) are stored somewhere.
So, my first thoughts go to using dynamic SQL. Supose you simply want to get the return from f1 (in your example) SELECTed from DUAL. Just do something like (again, referring to your example on how to get the function name):
EXECUTE IMMEDIATE 'SELECT '||
select substr(t1.udf_function,1,instr(t1.udf_function,'('))||t2.id||','||1||')' myfunc
from t1,
t2
where t2.id = 1
and t1.udf_function is not null||' FROM DUAL';
This is just a incomplete thought; no bind variables, etc... Use it as a starting point. The idea is to dynamically assemble SQL instructions with calls to «dynamic» functions...
DBMS_SQL comes to mind also, but haven't used it yet...
Cheers,
PMGuerra
Functions
Mike, August 22, 2007 - 7:45 am UTC
If you only need this function to be different at the database level, why not use a synonym ? It sounds like you are making the problem harder than it needs to be.