Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5Wag-000362-Rn for pgsql-general@arkaria.postgresql.org; Sun, 17 Mar 2019 14:16:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h5Waf-0007hI-GY for pgsql-general@arkaria.postgresql.org; Sun, 17 Mar 2019 14:16:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5WW6-0001Al-Ty for pgsql-general@lists.postgresql.org; Sun, 17 Mar 2019 14:11:58 +0000 Received: from portal-smtp-out.hot.ee ([194.126.101.122]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5WW4-0005cc-E4 for pgsql-general@postgresql.org; Sun, 17 Mar 2019 14:11:58 +0000 Received: from localhost (localhost [127.0.0.1]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id B4D43D5A; Sun, 17 Mar 2019 16:11:55 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at vm-hot-relay10.estpak.ee Received: from portal-smtp-out.hot.ee ([127.0.0.1]) by localhost (vm-hot-relay10.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8oSI7i8jgmRO; Sun, 17 Mar 2019 16:11:54 +0200 (EET) Received: from mail.hot.ee (hot-relayhost1.estpak.ee [213.180.2.79]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 8C1B7D42; Sun, 17 Mar 2019 16:11:54 +0200 (EET) Received: from dell2 (66-63-196-88.sta.estpak.ee [88.196.63.66]) (Authenticated sender: kobruleht2) by HOT-Relayhost1.estpak.ee (Postfix) with ESMTPSA id 44Mh892mx7z6y; Sun, 17 Mar 2019 16:11:52 +0200 (EET) Message-ID: From: "Andrus" To: "Pavel Stehule" Cc: "pgsql-general" References: In-Reply-To: Subject: Re: How to parse XML in Postgres newer versions also Date: Sun, 17 Mar 2019 16:11:44 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_001E_01D4DCDC.1D8BBD00" X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk See on mitmeosaline MIME-vormingus sõnum. ------=_NextPart_000_001E_01D4DCDC.1D8BBD00 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi >This variant is working >postgres=3D# SELECT=20 > (xpath('/ns:Ntry/ns:Amt/text()', x,nsa))[1]::text::numeric AS = tasusumma=20 > FROM (=20 > SELECT = unnest(xpath('/ns:Document/ns:BkToCstmrStmt/ns:Stmt/ns:Ntry',=20 >x,nsa)) as x,=20 > nsa=20 > FROM t=20 > ) Ntry=20 >;=20 >But I have not a idea, why old code doesn't work. It is little bit = strange so it worked without namespace before Amt tag.=20 In 9.1.5 it returns nulls=20 In 9.1.5 without namespaces (xpath('Amt/text()', x,nsa))[1]::text::numeric AS tasusumma works. How to make it work in both versions? Is it possible add some CASE WHEN or IF command or any other idea ? Andrus. ------=_NextPart_000_001E_01D4DCDC.1D8BBD00 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi
 
>This variant is working
>postgres=3D#  SELECT
>   =20 (xpath('/ns:Ntry/ns:Amt/text()', x,nsa))[1]::text::numeric AS tasusumma=20
>    FROM (=20
>        SELECT=20 unnest(xpath('/ns:Document/ns:BkToCstmrStmt/ns:Stmt/ns:Ntry', =
>x,nsa)) as=20 x,
>        nsa=20
>        FROM t=20
>    ) Ntry
>;
>But I have not a idea, why old code doesn't work. It is little = bit=20 strange so it worked without namespace before Amt tag.
In 9.1.5 it returns nulls
 
In 9.1.5 without namespaces
 
(xpath('Amt/text()', x,nsa))[1]::text::numeric AS tasusumma
 
works.
 
How to make it work in both versions?
Is it possible add some CASE WHEN or IF command  or any other = idea=20 ?
 
Andrus.
------=_NextPart_000_001E_01D4DCDC.1D8BBD00--