problem with check constraints

Started by Anton Andreevover 17 years ago3 messagesgeneral
Jump to latest
#1Anton Andreev
antonandreev@fmi.uni-sofia.bg

Hi,

When I create a check constraint in PgAdmin3 1.8.4 on a Postgresql
8.3.3: ((A and B) or (C and D))
I get with create script: (A and B or C and D) which is wrong.

Please help.

Cheers,
Anton

#2Julius Tuskenis
julius@nsoft.lt
In reply to: Anton Andreev (#1)
Re: problem with check constraints

Hello, Anton

Its ok, because conjunction (AND) has priority over disjunction (OR) so
((A and B) or (C and D)) = (A and B or C and D)

Anton Andreev rašė:

Hi,

When I create a check constraint in PgAdmin3 1.8.4 on a Postgresql
8.3.3: ((A and B) or (C and D))
I get with create script: (A and B or C and D) which is wrong.

Please help.

Cheers,
Anton

--
Julius Tuskenis
Programavimo skyriaus vadovas
UAB nSoft
mob. +37068233050

#3Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Anton Andreev (#1)
Re: [GENERAL] problem with check constraints

Anton Andreev wrote:

When I create a check constraint in PgAdmin3 1.8.4 on a Postgresql
8.3.3: ((A and B) or (C and D))
I get with create script: (A and B or C and D) which is wrong.

No, it isn't - both are the same.

AND has higher operator precedence than OR, see
http://www.postgresql.org/docs/8.3/static/sql-syntax-lexical.html#SQL-PRECEDENCE-TABLE

Yours,
Laurenz Albe