Re: parse error for function def - Mailing list pgsql-sql

From greg@turnstep.com
Subject Re: parse error for function def
Date
Msg-id c18dcb6ef4c84258e162e0069d993718@biglumber.com
Whole thread Raw
In response to parse error for function def  (Terence Kearns <terencek@isd.canberra.edu.au>)
List pgsql-sql
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> I'm trying to create a function to use on a trigger to check reference 
> to views since pg does not support foreign keys referencing views.

Can you explain exactly what you are trying to do and why? You are getting 
the error because a SQL function does not RETURN, it must end with a 
SELECT statement. It also has no DECLARE, BEGIN, or END. You can either 
remove all of those or change the language to plpgsql. See:

http://www.postgresql.org/docs/7.3/static/xfunc-sql.html

In addition, you cannot (with SQL) use an argument as the tablename. You 
also probably want to use EXISTS, not "count..::bool".

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200307171005

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE/Fq/7vJuQZxSWSsgRAj01AKCz9BA4aYrp8pnqWy8VHA4i3WGjtgCgjndA
yzNOE52VAvJBOEvilACSGvA=
=EcwZ
-----END PGP SIGNATURE-----




pgsql-sql by date:

Previous
From: "Viorel Dragomir"
Date:
Subject: Re: Is it possible to connect to another database
Next
From: Dmitry Tkach
Date:
Subject: Re: parse error for function def