X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id AC394CC8D7 for ; Thu, 17 Jul 2003 14:18:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 36613-04 for ; Thu, 17 Jul 2003 14:19:16 +0000 (GMT) Received: from biglumber.com (biglumber.com [207.228.252.42]) by svr1.postgresql.org (Postfix) with SMTP id 2C122CC9E3 for ; Thu, 17 Jul 2003 11:18:50 -0300 (ADT) Received: (qmail 14038 invoked from network); 17 Jul 2003 14:19:19 -0000 Received: from biglumber.com (HELO localhost) (207.228.252.42) by 0 with SMTP; 17 Jul 2003 14:19:19 -0000 From: greg@turnstep.com To: pgsql-sql@postgresql.org Cc: terencek@isd.canberra.edu.au Cc: terencek@isd.canberra.edu.au Subject: Re: parse error for function def X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 X-Request-PGP: http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 In-Reply-To: <3F167E9D.2090709@cts.canberra.edu.au> Date: Thu, 17 Jul 2003 14:19:19 -0000 X-Mailer: JoyMail 1.37 Message-ID: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/218 X-Sequence-Number: 14332 -----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-----