-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> CHECK (testconstraint(a, b))
Uhhh. I get no errors, but it dosen't work, either. Consider:
CREATE FUNCTION testconstraint(int,int) RETURNS bool AS '
BEGIN
RETURN (select sum(a) FROM test WHERE b = $2) < 1000;
END;
' LANGUAGE 'plpgsql';
CREATE TABLE test (a int, b int, CHECK (testconstraint(a,b)));
INSERT INTO test (a,b) VALUES (1100, 1);
SELECT * FROM test;
Yielding:
a | b
- ------+---
1100 | 1
(1 row)
which clearly does not satisfy the constraint.
Ian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE5s8/6fn9ub9ZE1xoRAuiRAKCHh/wWSl7uYzhJGWnc7kc0OxqZogCgpMCN
MdTBSXm7w0C4R4Ghh77+8ok=
=nik7
-----END PGP SIGNATURE-----