pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Postgres 9.2 - XML string functions ?
3+ messages / 2 participants
[nested] [flat]

* Postgres 9.2 - XML string functions ?
@ 2015-01-27 04:25  Khangelani Gama <kgama@argility.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Khangelani Gama @ 2015-01-27 04:25 UTC (permalink / raw)
  To: pgsql-admin

Hi



Please help, I have been asked why XML string functions do this, which is
why does the second statement below return no rows. No matter what is on
the select statement, they can select as many columns as they want but the
XML function breaks it as soon as it is added.





1)      select
aud_id,act_typ,right(act_typ::text,1),fpp_cde,obo_aud_id,obo_aud_id||sku_cde
as "Key" from sku_tran join audit using (aud_id) join action_typ using
(act_typ) join branch using (br_cde) join sku using (sku_cde) where
obo_aud_id=5252005 and audit.fpp_cde between '201408' and '201412' and
(right(act_typ::text,1) = '5') and act_typ between 76000 and 76999;

aud_id  | act_typ | right | fpp_cde | obo_aud_id |       Key

2585912 |   76005 | 5     | 201408  |    5252005 | 525200510053486

(1 row)

2)      select
aud_id,act_typ,right(act_typ::text,1),fpp_cde,obo_aud_id,(unnest(xpath('.//checksumBr/text()',
aud_xml::xml)))::text||obo_aud_id||sku_cde as "Key" from sku_tran join
audit using (aud_id) join action_typ using (act_typ) join branch using
(br_cde) join sku using (sku_cde) where obo_aud_id=5252005 and
audit.fpp_cde between '201408' and '201412' and (right(act_typ::text,1) =
'5') and act_typ between 76000 and 76999;

aud_id | act_typ | right | fpp_cde | obo_aud_id | Key

(0 rows)



CONFIDENTIALITY NOTICE
The contents of and attachments to this e-mail are intended for the addressee only, and may contain the confidential
information of Argility (Proprietary) Limited and/or its subsidiaries. Any review, use or dissemination thereof by anyone
other than the intended addressee is prohibited.If you are not the intended addressee please notify the writer immediately
and destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries distance themselves from and accept no liability
for unauthorised use of their e-mail facilities or e-mails sent other than strictly for business purposes.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Postgres 9.2 - XML string functions ?
@ 2015-01-27 05:21  David G Johnston <david.g.johnston@gmail.com>
  parent: Khangelani Gama <kgama@argility.com>
  0 siblings, 1 reply; 3+ messages in thread

From: David G Johnston @ 2015-01-27 05:21 UTC (permalink / raw)
  To: pgsql-admin

Khangelani Gama-2 wrote
> Hi
> 
> 
> 
> Please help, I have been asked why XML string functions do this, which is
> why does the second statement below return no rows. No matter what is on
> the select statement, they can select as many columns as they want but the
> XML function breaks it as soon as it is added.
> 
> 
> 
> 
> 
> 1)      select
> aud_id,act_typ,right(act_typ::text,1),fpp_cde,obo_aud_id,obo_aud_id||sku_cde
> as "Key" from sku_tran join audit using (aud_id) join action_typ using
> (act_typ) join branch using (br_cde) join sku using (sku_cde) where
> obo_aud_id=5252005 and audit.fpp_cde between '201408' and '201412' and
> (right(act_typ::text,1) = '5') and act_typ between 76000 and 76999;
> 
> aud_id  | act_typ | right | fpp_cde | obo_aud_id |       Key
> 
> 2585912 |   76005 | 5     | 201408  |    5252005 | 525200510053486
> 
> (1 row)
> 
> 2)      select
> aud_id,act_typ,right(act_typ::text,1),fpp_cde,obo_aud_id,(unnest(xpath('.//checksumBr/text()',
> aud_xml::xml)))::text||obo_aud_id||sku_cde as "Key" from sku_tran join
> audit using (aud_id) join action_typ using (act_typ) join branch using
> (br_cde) join sku using (sku_cde) where obo_aud_id=5252005 and
> audit.fpp_cde between '201408' and '201412' and (right(act_typ::text,1) =
> '5') and act_typ between 76000 and 76999;
> 
> aud_id | act_typ | right | fpp_cde | obo_aud_id | Key
> 
> (0 rows)

When you unnest an empty array it returns an empty set.  An empty set in the
select list causes the row it is sourced from to be excluded from the
output.

You can use a correlated subselect to instead have the result instead be
shown as NULL.

David J.




--
View this message in context: http://postgresql.nabble.com/Postgres-9-2-XML-string-functions-tp5835578p5835589.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.


-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Postgres 9.2 - XML string functions ?
@ 2015-01-27 05:25  Khangelani Gama <kgama@argility.com>
  parent: David G Johnston <david.g.johnston@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Khangelani Gama @ 2015-01-27 05:25 UTC (permalink / raw)
  To: David G Johnston <david.g.johnston@gmail.com>; pgsql-admin

Thank you very much

-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of David G Johnston
Sent: 27 January 2015 07:21 AM
To: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Postgres 9.2 - XML string functions ?

Khangelani Gama-2 wrote
> Hi
>
>
>
> Please help, I have been asked why XML string functions do this, which
> is why does the second statement below return no rows. No matter what
> is on the select statement, they can select as many columns as they
> want but the XML function breaks it as soon as it is added.
>
>
>
>
>
> 1)      select
> aud_id,act_typ,right(act_typ::text,1),fpp_cde,obo_aud_id,obo_aud_id||s
> ku_cde as "Key" from sku_tran join audit using (aud_id) join
> action_typ using
> (act_typ) join branch using (br_cde) join sku using (sku_cde) where
> obo_aud_id=5252005 and audit.fpp_cde between '201408' and '201412' and
> (right(act_typ::text,1) = '5') and act_typ between 76000 and 76999;
>
> aud_id  | act_typ | right | fpp_cde | obo_aud_id |       Key
>
> 2585912 |   76005 | 5     | 201408  |    5252005 | 525200510053486
>
> (1 row)
>
> 2)      select
> aud_id,act_typ,right(act_typ::text,1),fpp_cde,obo_aud_id,(unnest(xpath
> ('.//checksumBr/text()', aud_xml::xml)))::text||obo_aud_id||sku_cde as
> "Key" from sku_tran join audit using (aud_id) join action_typ using
> (act_typ) join branch using
> (br_cde) join sku using (sku_cde) where obo_aud_id=5252005 and
> audit.fpp_cde between '201408' and '201412' and
> (right(act_typ::text,1) =
> '5') and act_typ between 76000 and 76999;
>
> aud_id | act_typ | right | fpp_cde | obo_aud_id | Key
>
> (0 rows)

When you unnest an empty array it returns an empty set.  An empty set in
the select list causes the row it is sourced from to be excluded from the
output.

You can use a correlated subselect to instead have the result instead be
shown as NULL.

David J.




--
View this message in context:
http://postgresql.nabble.com/Postgres-9-2-XML-string-functions-tp5835578p5
835589.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.


--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make
changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin


CONFIDENTIALITY NOTICE
The contents of and attachments to this e-mail are intended for the addressee only, and may contain the confidential
information of Argility (Proprietary) Limited and/or its subsidiaries. Any review, use or dissemination thereof by anyone
other than the intended addressee is prohibited.If you are not the intended addressee please notify the writer immediately
and destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries distance themselves from and accept no liability
for unauthorised use of their e-mail facilities or e-mails sent other than strictly for business purposes.



-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2015-01-27 05:25 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-01-27 04:25 Postgres 9.2 - XML string functions ? Khangelani Gama <kgama@argility.com>
2015-01-27 05:21 ` David G Johnston <david.g.johnston@gmail.com>
2015-01-27 05:25   ` Khangelani Gama <kgama@argility.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox