| From: | "Andrus" <kobruleht2(at)hot(dot)ee> |
|---|---|
| To: | "David Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
| Cc: | <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Converting xml to table with optional elements |
| Date: | 2014-11-28 16:40:48 |
| Message-ID: | 203BD69201BA441DAFD612CBB2777EA8@dell2 |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi!
Thank you.
>Subquery the xpath expression to unnest it and apply a LIMIT 1
> UPDATE tbl SET ... = (SELECT xpath( tbl.???[...] ) LIMIT 1)
I used unnest() :
update temprid set
ContactFirstName =unnest(xpath(
'/E-Document/Document/DocumentParties/BuyerParty/ContactData/ContactFirstName/text()',x))::text
Is this OK ?
>Note that I do not believe your example code is going to work. As I mentioned you really want to create a >table of documents and NOT try to pair up multiple unnested columns.
How to create table of documents ?
xml contains multiple products and document info.
Code creates table containing one row for every product and adds same header fields to all rows.
Whu this will not work ?
Andrus.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Johnston | 2014-11-28 16:55:34 | Re: Converting xml to table with optional elements |
| Previous Message | Misa Simic | 2014-11-28 16:05:25 | Re: PG94RC1- plv8 functions - problem with input parameter length |