Re: Multiline plpython procedure

From: Adrian Klaver <aklaver(at)comcast(dot)net>
To: Hong Yuan <hongyuan(at)homemaster(dot)cn>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Multiline plpython procedure
Date: 2005-01-17 14:31:49
Message-ID: 200501170631.49113.aklaver@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday 17 January 2005 01:54 am, Hong Yuan wrote:
I entered the multilineversion of this function exactly as written here and it
ran properly. This was with version 8.0 of Postgres. You might want to do
a /df+ circ in psql to see if your editor is putting a space at the beginning
of line 2.
> Hi,
>
> I am biwildered at how to create a multi-line plpython function in
> Postgres. When I create the function in one line like this:
>
> CREATE or REPLACE FUNCTION circ (float)
> RETURNS float AS 'from math import pi; return 2*pi*args[0]' LANGUAGE
> plpythonu;
>
> and then use SELECT circ(1) to test it, it runs well.
>
> But if I try to make the code looks better by separating it into
> mulitple lines, like this:
>
> CREATE or REPLACE FUNCTION circ (float)
> RETURNS float AS '
> from math import pi
> return 2*pi*args[0]' LANGUAGE plpythonu;
>
> I got an error message:
>
> ERROR: plpython: could not compile function "circ"
> DETAIL: exceptions.SyntaxError: invalid syntax (line 2)
>
> How to get Postgres to accept a normal looking python function?
>
> Greetings

--
Adrian Klaver
aklaver(at)comcast(dot)net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mike Rylander 2005-01-17 15:15:35 Re: Array to rowset function
Previous Message laurie.burrow 2005-01-17 14:03:56 Array to rowset function