Re: Can I use a constraint to make sure all array elements are positive?

From: Vik Fearing <vik(dot)fearing(at)dalibo(dot)com>
To: AlexK <alkuzo(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Can I use a constraint to make sure all array elements are positive?
Date: 2014-03-19 22:08:19
Message-ID: 532A1553.1050008@dalibo.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 03/19/2014 10:59 PM, AlexK wrote:
> One of the columns in my table is FLOAT[] NOT NULL. Can I use a constraint to
> make sure all array elements are positive?

You can make a function that checks an array, and then use that in a
CHECK constraint.

Also, note that select array[null]::float[] is null; returns false.
That may not be what you want.

--
Vik

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Sergey Konoplev 2014-03-19 22:20:57 Re: Can I use a constraint to make sure all array elements are positive?
Previous Message AlexK 2014-03-19 21:59:36 Can I use a constraint to make sure all array elements are positive?