Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQOfQ-0004UL-Di for pgsql-sql@arkaria.postgresql.org; Wed, 19 Mar 2014 22:08:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WQOfP-0004MX-T0 for pgsql-sql@arkaria.postgresql.org; Wed, 19 Mar 2014 22:08:55 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQOfO-0004MQ-Pw for pgsql-sql@postgresql.org; Wed, 19 Mar 2014 22:08:54 +0000 Received: from mimolette.dalibo.net ([212.85.154.222]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQOfM-0004D3-CD for pgsql-sql@postgresql.org; Wed, 19 Mar 2014 22:08:54 +0000 Received: from [192.168.0.38] (ip-68.net-81-220-133.standre.rev.numericable.fr [81.220.133.68]) by mimolette.dalibo.net (Postfix) with ESMTPSA id 98454682000E; Wed, 19 Mar 2014 23:08:21 +0100 (CET) Message-ID: <532A1553.1050008@dalibo.com> Date: Wed, 19 Mar 2014 23:08:19 +0100 From: Vik Fearing User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: AlexK , pgsql-sql@postgresql.org Subject: Re: Can I use a constraint to make sure all array elements are positive? References: <1395266376754-5796846.post@n5.nabble.com> In-Reply-To: <1395266376754-5796846.post@n5.nabble.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql