Re: Unable to convert xpath value to date

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Unable to convert xpath value to date
Date: 2013-10-03 13:10:51
Message-ID: 1380805851428-5773223.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

saritha N wrote
> ERROR: invalid value "{0" for "dd"
> DETAIL: Value must be an integer.

The leading "{" in the data is the big give away. This is how a string
representation of an array looks. From the documentation:

http://www.postgresql.org/docs/9.3/interactive/functions-xml.html

> The function xpath evaluates the XPath expression xpath (a text value)
> against the XML value xml. It returns an array of XML values corresponding
> to the node set produced by the XPath expression. If the XPath expression
> returns a scalar value rather than a node set, a single-element array is
> returned.

If you want to convert the result of an xpath query you need to operate over
an array. Usually that means unnesting though there are other
possibilities. If you know you are only dealing (or care about) the first
element you can simply code it as (xpath(...))[1] - note the surrounding
parentheses - to get that first element.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Unable-to-convert-xpath-value-to-date-tp5773204p5773223.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Simeó Reig 2013-10-03 13:21:18 pgbench
Previous Message Berend Tober 2013-10-03 12:25:08 Re: Whole record returned in stead of field