Re: Passing array of range literals

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Passing array of range literals
Date: 2014-03-21 18:51:49
Message-ID: 1395427909148-5797062.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Glenn Pierce wrote
> I cannot work out how to pass a literal for the array of timerange types.
> '{(15:11:21, 18:11:21)}'::timerange[] does not work for example.
> Also I can not pass NULL for this parameter I get

since NULL can take on any type if you pass it literally you have to specify
the type you need:

NULL::timerange[]

Though I'd suggest passing in an empty array instead:

ARRAY[]::timerange[]

Note this is also the best way to construct the array:

ARRAY['(15:11:21,18:11:21)','(19.11.22,21:12:17]']::timerange[]

Otherwise you need to use double-quotes somewhere. Once you construct an
array as above just cast it to text and let PostgreSQL tell you what the
text representation would look like if you cannot use the ARRAY[] form.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Passing-array-of-range-literals-tp5797031p5797062.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shaun Thomas 2014-03-21 19:32:50 Introducing walctl, a simple tool for safe WAL management
Previous Message Ken Barber 2014-03-21 17:46:29 General Advice for avoiding concurrency during schema migrations