pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCan I use subselect as a function parameter?
3+ messages / 3 participants
[nested] [flat]
* Can I use subselect as a function parameter?
@ 2000-10-11 13:42 Oliver Elphick <olly@lfix.co.uk>
2000-10-11 14:55 ` Re: Can I use subselect as a function parameter? Philip Warner <pjw@rhyme.com.au>
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Elphick @ 2000-10-11 13:42 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Can I use subselect as a function parameter?
2000-10-11 13:42 Can I use subselect as a function parameter? Oliver Elphick <olly@lfix.co.uk>
@ 2000-10-11 14:55 ` Philip Warner <pjw@rhyme.com.au>
2000-10-11 14:25 ` Re: Can I use subselect as a function parameter? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Philip Warner @ 2000-10-11 14:55 UTC (permalink / raw)
To: Oliver Elphick <olly@lfix.co.uk>; pgsql-sql
At 14:42 11/10/00 +0100, Oliver Elphick wrote:
>
> 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
> )
>);
>
>
>Can this be made to work at all (in 7.0.2)?
>
The short answer is that subselect in CHECK is not currently supported, and
is not planned for 7.1.
There was a thread about subselect in CHECK not so long ago (see 'checking
number of entries' on or around the 29/9). There was apparently also an
earlier discussion in which the meaning were not deemed to be clear. I
think the most recent discussion at least resolved the meaning, but not the
locking issues.
----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Can I use subselect as a function parameter?
2000-10-11 13:42 Can I use subselect as a function parameter? Oliver Elphick <olly@lfix.co.uk>
2000-10-11 14:55 ` Re: Can I use subselect as a function parameter? Philip Warner <pjw@rhyme.com.au>
@ 2000-10-11 14:25 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2000-10-11 14:25 UTC (permalink / raw)
To: Philip Warner <pjw@rhyme.com.au>; +Cc: Oliver Elphick <olly@lfix.co.uk>; pgsql-sql
Philip Warner <pjw@rhyme.com.au> writes:
> The short answer is that subselect in CHECK is not currently supported, and
> is not planned for 7.1.
We should, however, try to make 7.1 deliver a more helpful error message
;-). I've put a note about it on my todo list.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2000-10-11 14:55 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-10-11 13:42 Can I use subselect as a function parameter? Oliver Elphick <olly@lfix.co.uk>
2000-10-11 14:55 ` Philip Warner <pjw@rhyme.com.au>
2000-10-11 14:25 ` Tom Lane <tgl@sss.pgh.pa.us>
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