-----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 <[EMAIL PROTECTED]>
http://www.stuartbishop.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

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

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to