Re: plpython question

Поиск
Список
Период
Сортировка
От Stuart Bishop
Тема Re: plpython question
Дата
Msg-id 4175F9AA.4000900@stuartbishop.net
обсуждение исходный текст
Ответ на plpython question  (Sim Zacks <sim@compulab.co.il>)
Ответы Re: plpython question
Список 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 по дате отправления:

Предыдущее
От: Weiping
Дата:
Сообщение: Re: About upper() and lower to handle multibyte char
Следующее
От: Stuart Bishop
Дата:
Сообщение: Re: plpython question