Re: plpython question

From: Stuart Bishop <stuart(at)stuartbishop(dot)net>
To: Sim Zacks <sim(at)compulab(dot)co(dot)il>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: plpython question
Date: 2004-10-20 05:37:46
Message-ID: 4175F9AA.4000900@stuartbishop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sim Zacks wrote:
| I have the following function and I am getting an invalid syntax error
| when I try to run it. I have tried the function a number of ways
| including with named parameters and non-named parameters using the
| args array. I also tried it with a tab at the beginning and without.
| I've also tried with the $$ and with single quotes and the double
| single quoting all the existing single quotes.
|
| Any help would be greatly appreciated.

Easier to help if you actually give the error message, and what version
of PostgreSQL you are running might be significant too.

| create or replace function BatchBalanceStatus(balance int, needed int,
freestock int) returns varchar as
| $$
| if balance < 0:
| return 'Unhandled'
| elif freestock >= needed:
| return 'OK'
| else:
| return 'Ordered'
| $$ language plpythonu

create or replace function BatchBalanceStatus(int, int, int) returns
varchar as '
~ balance, needed, freestock = args
~ if balance < 0:
~ return "Unhandled"
~ elif freestock >= needed:
~ return "OK"
~ else:
~ return "Ordered"
' language plpythonu;

Works just fine here on 7.4.5

- --
Stuart Bishop <stuart(at)stuartbishop(dot)net>
http://www.stuartbishop.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBdfmqAfqZj7rGN0oRAiipAJ9X3IoxinVNx/JRwF9OlzSsZMAATQCgh636
b4kuADMg75BBHqaDjV55c+4=
=LMiW
-----END PGP SIGNATURE-----

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stuart Bishop 2004-10-20 05:40:04 Re: plpython question
Previous Message Weiping 2004-10-20 03:37:32 Re: About upper() and lower to handle multibyte char