From: Oliver Elphick <olly@lfix.co.uk>
To: pgsql-sql@postgresql.org
Subject: Can I use subselect as a function parameter?
Date: Wed, 11 Oct 2000 14:42:05 +0100
Message-ID: <200010111342.e9BDg5Y26824@linda.lfix.co.uk> (raw)
I want to do this:
CREATE FUNCTION ean_checkdigit(bpchar, bpchar) RETURNS BOOLEAN
AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE 'C';
CREATE TABLE product (
id CHAR(10) PRIMARY KEY,
brand CHAR(12) REFERENCES brandname(id)
ON UPDATE CASCADE
ON DELETE NO ACTION,
eancode CHAR(6) CHECK (eancode IS NULL
OR eancode ~ '[0-9]{6}'),
...,
CONSTRAINT ean CHECK (
CASE WHEN eancode IS NULL OR brand IS NULL
THEN 't'
ELSE ean_checkdigit(
(SELECT ean_prefix
FROM brandname, product
WHERE brandname.id = product.brand
), eancode)
END
)
);
The parser accepts it, but when it is run on a line that matches the ELSE in the constraint, I get:
copy product from '/usr1/avoca/dumps/dbdump.product'
ERROR: copy: line 2, ExecEvalExpr: unknown expression type 108
Can this be made to work at all (in 7.0.2)?
--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"I waited patiently for the LORD; and he inclined unto
me, and heard my cry. He brought me up also out of an
horrible pit, out of the miry clay, and set my feet
upon a rock, and established my goings."
Psalms 40:1,2
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: olly@lfix.co.uk
Subject: Re: Can I use subselect as a function parameter?
In-Reply-To: <200010111342.e9BDg5Y26824@linda.lfix.co.uk>
References: <200010111342.e9BDg5Y26824@linda.lfix.co.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox