@@ -209,17 +209,20 @@ def return_type(arguments: List[Argument]):
209209
210210
211211class Overload :
212- def __init__ (self , arguments ):
212+ def __init__ (self , arguments : Iterator [ Argument ] ):
213213 self .arguments = list (arguments )
214214
215- self .return_type = return_type (self .arguments )
215+ self .return_type : Argument = return_type (self .arguments )
216216
217217 self .arguments = [
218218 argument
219219 for argument in self .arguments
220220 if argument .position and argument .datatype
221221 ]
222222
223+ def match (self , * args , ** kwargs ) -> bool :
224+ return (len (args ) + len (kwargs )) == len (self .arguments )
225+
223226
224227def group_by_overload (arguments : Iterator [Argument ]) -> List [Overload ]:
225228 return [
@@ -236,12 +239,30 @@ def __init__(
236239
237240 self .overloads = group_by_overload (arguments = arguments )
238241
242+ def __call__ (self , * args , ** kwargs ):
243+ if not self ._match (* args , ** kwargs ):
244+ raise ValueError ("Arguments do not match subprogram" )
245+
246+ with self .plsql ._connection .cursor () as cursor :
247+ cursor .callproc (self .resolved .name , * args , ** kwargs )
248+
249+ def _matches (self , * args , ** kwargs ) -> List [Overload ]:
250+ return [
251+ overload for overload in self .overloads if overload .match (* args , ** kwargs )
252+ ]
253+
254+ def _match (self , * args , ** kwargs ) -> bool :
255+ return bool (self ._matches (* args , ** kwargs ))
256+
239257 @property
240258 def overloaded (self ) -> bool :
259+ """returns true if exists multiple definitions of the same subprogram in a package
260+ only applicable for package procedures/functions where overloading is possible"""
241261 return len (self .overloads ) > 1
242262
243263 @property
244264 def standalone (self ) -> bool :
265+ """returns true if procedure/function is not part of a package"""
245266 return self .resolved .object_type in {
246267 ObjectTypes .procedure ,
247268 ObjectTypes .function ,
0 commit comments