Re: Passing array of range literals - Mailing list pgsql-general

From David Johnston
Subject Re: Passing array of range literals
Date
Msg-id 1395427909148-5797062.post@n5.nabble.com
Whole thread Raw
In response to Passing array of range literals  (Glenn Pierce <glennpierce@gmail.com>)
List 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.


pgsql-general by date:

Previous
From: Ken Barber
Date:
Subject: General Advice for avoiding concurrency during schema migrations
Next
From: Shaun Thomas
Date:
Subject: Introducing walctl, a simple tool for safe WAL management