-------------- Original message ----------------------
From: "user" <2567jl03@sneakemail.com>
> I am having a problem with the simplest of Python functions, so I must be
> doing something wrong. After hours of searching and trying many options, I
> need the key that my puny brain is missing here.
>
> I cannot pass parameters to a plpythonu function. I have tried within psql
> and with pgAdmin III (which adds IN or INOUT to the parameter list - which I
> can't find documented). I'm an advanced Python programmer but a beginning
> PostgreSQL user.
>
> Here is what I have, which I copied almost verbatim from example code:
> ----------------------------
> test_dev-# \p
> create or replace function testf5i(a integer,b integer)
> RETURNS integer AS $$
> if a > b:
> return a
> return b
> $$ language plpythonu
>
>
> test_dev-# \g
> CREATE FUNCTION
> test_dev=# select testf5i(1,2);
> ERROR: plpython: function "testf5i" failed
> DETAIL: exceptions.NameError: global name 'a' is not defined
Take a look at:
http://www.postgresql.org/docs/8.1/interactive/plpython.html#PLPYTHON-FUNCS
The form you are trying to use is supported in 8.2+.
--
Adrian Klaver
aklaver@comcast.net