Re: Question from a newbie

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kiarash Bodouhi" <kbodouhi(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Question from a newbie
Date: 2004-10-08 02:55:03
Message-ID: 27670.1097204103@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Kiarash Bodouhi" <kbodouhi(at)yahoo(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-10-08 03:04:41 Re: Fix setArray() when using the v3 protocol (was Re: Postgres 8.0 + JDBC)
Previous Message Tom Lane 2004-10-08 02:35:10 Re: Index problem.... GIST (tsearch2)