Forum OpenACS Development: Re: Is package_exec_plsql able to handle multiple definitions of the same function (PG)?

Package exec plsql is not supposed to support multiple define_function_args.

Remember the point of package_exec_plsql is to call the excat same procedure in oracle and postgresql. So the postgresql plpgsql function that is called needs to have the same parameters as the oracle version.

You can not have multiple plpgsql functions with the same number of params with OpenACS since the bind variable emulation turns most parameters into strings by quoting them. So in this case postgresql can only guess the correct function based on the number of parameters.

What you need to do is create a content_template__new that is exactly the same as the oracle version with all the same parameters. If you need to add an OPTIONAL parameter to both Oracle and PG, then you need to create a new PG function with more parameters and remove the old define function args call and create a new one for the function with the new parameter.

I think PG knows which function is being called based on the number and type of the params.

Also, then, package_exec_plsql cannot handle 2 or more function calls well unless there's a convention for the params. And I don't know exactly why there are multiple definitions of content_template__new while in oracle is just one .new.

The reason is so that its "easier" to call postgresql functions. For example content_item__new is up to 19 parameters last time I checked. There is a simplified version with 4 or 5 parameters that maybe use useful.

Remember that previous to package_exec_plsql and the drive to move most functions up into Tcl procedures there were many calls to plsql functions in XQL files. Now that we have package_exec_plsql and are moving more functions into Tcl procs, we don't really need the overloaded functions.

So to summarize, only the function that matches the oracle version should have define_function_args called for it. I fixed this for content_template__new on oacs-5-1 and HEAD with an upgrade script.

I see the reason, then we can gradually get rid of those mini-functions, also, there are problems with __del as well. Thanks for the help!