Re: plpython question - Mailing list pgsql-general

From Stuart Bishop
Subject Re: plpython question
Date
Msg-id 4175F9AA.4000900@stuartbishop.net
Whole thread Raw
In response to plpython question  (Sim Zacks <sim@compulab.co.il>)
Responses Re: plpython question  (Stuart Bishop <stuart@stuartbishop.net>)
List 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@stuartbishop.net>
http://www.stuartbishop.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

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

pgsql-general by date:

Previous
From: Weiping
Date:
Subject: Re: About upper() and lower to handle multibyte char
Next
From: Stuart Bishop
Date:
Subject: Re: plpython question