Issue 12 in orapig: Optional Function Arguments

0 views
Skip to first unread message

codesite...@google.com

unread,
Jun 17, 2008, 12:27:32 AM6/17/08
to orapi...@googlegroups.com
Issue 12: Optional Function Arguments
http://code.google.com/p/orapig/issues/detail?id=12

New issue report by MarkRoddy:
For package functions/procedures that have arguments with default values,
have these default values in the Python method. So:
FUNCTION Foo(arg integer default 1);

Would yield:
def Foo(self, arg=1)


Issue attributes:
Status: Accepted
Owner: MarkRoddy
Labels: Type-Enhancement Priority-Medium

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

Henning

unread,
Jun 17, 2008, 4:09:09 AM6/17/08
to orapig-dev
I don't think this is possible the way you described it.

Default values may be constants from other packages or even something
like USER, not only literals.
The Python wrapper should perhaps use some use some internal object
USE_DEFAULT instead, if the default value is not a literal. It would
look like this, then:
def Foo(self, arg=USE_DEFAULT):
...

The implementation, however, will have to be more intelligent then,
because it has to construct the SQL string in a dynamic fashion, like
this (untested, but you get the idea):
optargs = {}
if arg is not USE_DEFAULT:
optargs["arg"] = arg
argstr = ", ".join([(k + "=> :" + k) for k,v in optargs.items()])
sql = "begin :ret := PCK.Foo(%s); end;" % argstr
curs.execute(sql, optargs)



Then the Python
"USE

Mark Roddy

unread,
Jun 17, 2008, 12:08:55 PM6/17/08
to orapig-dev
Henning,
Thanks for the insight. I assumed the 'Default_Value' column in the
user_arguments view would provide this information. I didn't realize
it is currently useless:
http://www.dbforums.com/showthread.php?t=631096

I like the idea of the 'USE_DEFAULT'. The only thing I would change
is to use bind variables for the literal argument values. Otherwise
string values need to be quoted/escaped.

-Mark

Reply all
Reply to author
Forward
0 new messages