From: Goran Buzic <goran.buzic@hep.hr>
To: pgsql-sql@postgresql.org
Subject: POSIX-style regular expressions
Date: Tue, 10 Sep 2002 11:32:51 +0200
Message-ID: <alkea9$104o$1@news.hub.org> (raw)
Hi
Can anybody help me with POSIX-style regular expression used to check rules
that new data must satisfy for an insert or update operetion.
Table was created as follows.
CREATE TABLE table_name1 (
id1 char(6) NOT NULL CHECK(id1 ~* '^([0-9]{1,2}\.){2}$'),
id2 INT NOT NULL,
CONSTRAINT primary_key
PRIMARY KEY (id1, id2),
CONSTRAINT id2_exists
FOREIGN KEY (id2) REFERENCES table_name2
ON DELETE CASCADE
ON INSERT CASCADE
);
Any id1 that looks like
1.2.
1.12.
12.1.
12.12.
should be inserted into table, but the insert query was rejected with an
error message
ERROR: ExecAppend: rejected due to CHECK constraint table_name1_id1
I tested preceding regular expression with Perl and JavaScript and it worked
fine. Can I use regular expressions with CHECK parametar, and if so, how can
I make it work.
The platform PostgreSQL is installed is Solaris 8 - Intel.
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: goran.buzic@hep.hr
Subject: Re: POSIX-style regular expressions
In-Reply-To: <alkea9$104o$1@news.hub.org>
* 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