POSIX-style regular expressions

From: "Goran Buzic" <goran(dot)buzic(at)hep(dot)hr>
To: pgsql-sql(at)postgresql(dot)org
Subject: POSIX-style regular expressions
Date: 2002-09-10 09:32:51
Message-ID: alkea9$104o$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Jore 2002-09-10 13:35:27 Re: POSIX-style regular expressions
Previous Message Bc. Šimko Juraj 2002-09-10 08:29:44 Help