"Kiarash Bodouhi" <kbodouhi@yahoo.com> writes:
> I have two questions. First, is it possible to call other functions
> from plpython functions? I used following but didn't work. Any comments?
> CREATE OR REPLACE FUNCTION test4()
> RETURNS "varchar" AS
> '
> return plpy.execute("select getcountrycode("9821788")",1)
> '
> LANGUAGE 'plpythonu' VOLATILE;
Didn't work how, exactly? I don't know much Python but I'd think you
have a quote-nesting mistake there. And anyway, shouldn't it be single
quotes in the SQL command, ie
return plpy.execute("select getcountrycode('9821788')",1)
which you actually need to write as
return plpy.execute("select getcountrycode(\'9821788\')",1)
because you're already inside a single-quoted string.
> Also, do you know any better way (apart from psql) to enter and test
> functions? I used pgAdmin, but it didn't work properly with plpython.
Dunno; it is certainly possible that pgAdmin isn't careful about
preserving leading indentation. I'd suggest taking that up with the
pgAdmin guys; I'm sure they'll fix it when you point out that python
is picky about this.
regards, tom lane