473,385 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

constraint expression

Hello,

I am having problems adding a simple expression to a table level
constraint.
Here is an example of one which postgresql 7.4.3 does not accept.

create table test (a int, b int, c int,
constraint aname check (((a=0) and (b is not null)) or ((a=1) and (c
is not null)));

Should this work? It is complaining 'ERROR: syntax error at or near
";" at character 126'

Thanks
Nov 23 '05 #1
2 1368
Roger Niederland wrote:
Hello,

I am having problems adding a simple expression to a table level
constraint.
Here is an example of one which postgresql 7.4.3 does not accept.

create table test (a int, b int, c int,
constraint aname check (((a=0) and (b is not null)) or ((a=1) and (c
is not null)));

Should this work? It is complaining 'ERROR: syntax error at or near
";" at character 126'


Works on 7.4:

regression=# create table test (a int, b int, c int,
regression(# constraint aname check (((a=0) and (b is not null)) or ((a=1) and (c
regression(# is not null))));
CREATE TABLE
you forgot to ")".


Regards
Gaetano Mendola


Nov 23 '05 #2


On Fri, 6 Aug 2004, Roger Niederland wrote:
create table test (a int, b int, c int,
constraint aname check (((a=0) and (b is not null)) or ((a=1) and (c
is not null)));


You are missing the closing ) for the create table statement.

Kris Jurka

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ron | last post by:
Mandatories: Ver 7.3.4, Redhat Linux 8.0, P4, 2GB RAM I want to add a 'nullable' foreign key to a column in a table. I have tables "company" and "project" which may be related by...
2
by: Bernhard Huemer | last post by:
using System; using System.Collections.Generic; public class CovariantList<T> : List<T> { // ... // of course this constraint won't work .. public CovariantList<U> Convert<U>() where U:...
6
by: lgbjr | last post by:
Hi All, I've posted this question on the ComponentOne news group, but I thought it couldn't hurt to post it here as well, since, I’m assuming, some others out there are using the C1 controls for...
3
by: ferg | last post by:
I have a Customer table. The table has two different CHECK constraints. Then there is the Customer details dialog, which provides the user with an UI for changing users. I have some UPDATE sql,...
5
by: HandersonVA | last post by:
if i have a table which defines a rule as "combination of two field must be unique", how can I write this in a constraint expression section? i started learning more about ms sql side to handle...
1
by: Spectre1337 | last post by:
Hello, it seems like the check constraint validation of MS SQL Server Management Studio express is horribly, horribly broken. Either that or I'm using it wrong. I hope it's the latter. I'm...
3
by: Helen Wheels | last post by:
Can we use parentheses in a check constraint in MS-SQL-server DDL? e.g. I'm having a problem with the following statement: ALTER TABLE . ADD CONSTRAINT CHECK (( IS NULL AND IS NULL) OR (...
1
by: tthunder | last post by:
Hi @all, Please check the following XML file and XML schema definition below first: ------- XML File (full): ------- <?xml version="1.0" encoding="UTF-8"?>
2
by: rorajoey | last post by:
Violation of UNIQUE KEY constraint 'IX_surveyQuestions'. Cannot insert duplicate key in object 'dbo.surveyQuestions'. This might seem like a simple matter of trying to insert a row with ID=20 when...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.