Multiline plpython procedure

From: Hong Yuan <hongyuan(at)homemaster(dot)cn>
To: pgsql-general(at)postgresql(dot)org
Subject: Multiline plpython procedure
Date: 2005-01-17 09:54:26
Message-ID: 41EB8B52.7020303@homemaster.cn
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

--
HONG Yuan
Homemaster Trading Co., Ltd.
No. 601, Bldg. 41, 288 Shuangyang Rd. (N)
Shanghai 200433, P.R.C.
Tel: +86 21 55056553
Fax: +86 21 55067325
E-mail: hongyuan(at)homemaster(dot)cn

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2005-01-17 10:05:55 Re: ntfs for windows port rc5-2
Previous Message Martijn van Oosterhout 2005-01-17 09:25:51 Re: Cursor bug?