Re: Question from a newbie

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Question from a newbie
Дата
Msg-id 27670.1097204103@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Question from a newbie  ("Kiarash Bodouhi" <kbodouhi@yahoo.com>)
Ответы Re: Question from a newbie  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-general
"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

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Index problem.... GIST (tsearch2)
Следующее
От: Dennis Gearon
Дата:
Сообщение: Re: flattened tables with normalized tables