Hi. I've made a small stored procedure un PL/python. This procedure retrieve python code from a row then execute it and calls a predefined function. Alls works well while no others functions are defined and called in the row retrieved code; I mean when I define the row retrieved code like this :
def powar(x): return x*x def make_transform(x,y): plpy.notice("viewed from make_transform : %s"%out) if x>2 and y >5: return powar(x+y) else: return x+y and when I execute the following python stored procedure: CREATE OR REPLACE FUNCTION tarage(NUMERIC,NUMERIC) RETURNS NUMERIC AS' qry = plpy.prepare("SELECT expression from fonctions where name = $1", ["text"]) res = plpy.execute(qry,["transf(x,y)"]) expression = res[0]["expression"] x=args[0] y=args[1] plpy.notice(expression) exec expression out = "%s"%dir() plpy.notice(out) b = make_transform(x,y) return b ' LANGUAGE 'plpython'; Here is the output : supervisor=# select tarage(4.0,2.0); NOTICE: ('\ndef powar(f):\n\treturn f*f\n\ndef make_transform(x,y):\n\tout = "%s"%dir()\n\tplpy.notice("viewed from make_transform : %s"%out)\n\tif x>2:\n\t\treturn powar(x)\n\telse:\n\t\treturn x+y\n',) NOTICE: ("['expression', 'make_transform', 'powar', 'qry', 'res', 'x', 'y']",) NOTICE: ("viewed from make_transform : ['x', 'y']",) ERROR: plpython: Call of function `tarage' failed. exceptions.NameError: global name 'powar' is not defined Well, I tried to recreate the restricted execution env, in my python console interpreter and I got the right result! So is there a way to get the whole things work (to make powar() visible from make_transform())? Thanks in advance? -- Jean-Christophe ARNU ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly