Re: Converting xml to table with optional elements

Поиск
Список
Период
Сортировка
От David G Johnston
Тема Re: Converting xml to table with optional elements
Дата
Msg-id 1417100609569-5828515.post@n5.nabble.com
обсуждение исходный текст
Ответ на Converting xml to table with optional elements  ("Andrus" <kobruleht2@hot.ee>)
Список pgsql-general
Andrus Moor wrote
> How to convert xml to table if some elements are optional in xml ?
>
> In XML
>
> /E-Document/Document/DocumentParties/BuyerParty/ContactData/ContactFirstName
> element is optional.
>
> If this is present, code below works OK.
> If ContactFirstName is not present , empty table is returned.
>
> How to extract product code rows if ContactFirstName element is missing ?
> In result ContactFirstName column should have null on other value.

You have to process this in two passes.

First pass you create a table of documents by unnesting the non-optional
Document elements.
Second pass you explode each individual row/document on that table into its
components.

David J.



--
View this message in context:
http://postgresql.nabble.com/Converting-xml-to-table-with-optional-elements-tp5828506p5828515.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


В списке pgsql-general по дате отправления:

Предыдущее
От: "Andrus"
Дата:
Сообщение: Converting xml to table with optional elements
Следующее
От: rob stone
Дата:
Сообщение: Re: Avoiding deadlocks when performing bulk update and delete operations