Re: Constraint: string length must be 32 chars

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Constraint: string length must be 32 chars
Date: 2010-10-16 17:00:26
Message-ID: 4CB9DA2A.3000506@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 16/10/2010 17:48, Alexander Farber wrote:
> snake=> create table gps (
> id varchar(32) primary key CONSTRAINT id_length char_length(id)=32,
> stamp timestamp DEFAULT current_timestamp,
> pos point);
> ERROR: syntax error at or near "char_length"
> LINE 2: id varchar(32) primary key CONSTRAINT id_length char_length(...
> ^
>
> snake=> create table gps (
> id varchar(32) primary key CHECK id_length char_length(id)=32,
> stamp timestamp DEFAULT current_timestamp,
> pos point);
> ERROR: syntax error at or near "id_length"
> LINE 2: id varchar(32) primary key CHECK id_length char_length(id)=3...
> ^
>
> snake=> create table gps (
> id varchar(32) primary key CHECK char_length(id)=32,
> stamp timestamp DEFAULT current_timestamp,
> pos point);
> ERROR: syntax error at or near "char_length"
> LINE 2: id varchar(32) primary key CHECK char_length(id)=32,
> ^
>
> Sorry, any ideas? (I know it's a stupid question)
> Alex
>

None of those correspond to what I suggested! :-)
Here is is again:

... CONSTRAINT length_check CHECK char_length(id) = 32, ...

Note the keywords "constraint" and "check" both present. Not that I'm
saying I'm correct - I'm going on memory.... If in doubt consult the
docs under "create table".

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2010-10-16 17:04:39 Re: Fastest way to check database's existence
Previous Message Alexander Farber 2010-10-16 16:48:51 Re: Constraint: string length must be 32 chars