Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFyeY-0002yI-Se for pgsql-admin@arkaria.postgresql.org; Tue, 27 Jan 2015 05:25:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFyeX-0003Ty-Qy for pgsql-admin@arkaria.postgresql.org; Tue, 27 Jan 2015 05:25:29 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFyeW-0003RK-Dh for pgsql-admin@postgresql.org; Tue, 27 Jan 2015 05:25:28 +0000 Received: from eu1sys200aog120.obsmtp.com ([207.126.144.149]) by makus.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFyeT-0001DF-0l for pgsql-admin@postgresql.org; Tue, 27 Jan 2015 05:25:26 +0000 Received: from mail-wg0-f47.google.com ([74.125.82.47]) (using TLSv1) by eu1sys200aob120.postini.com ([207.126.147.11]) with SMTP ID DSNKVMchQI7ZZFTY1WTnXuQUnzl5lUUCqhdh@postini.com; Tue, 27 Jan 2015 05:25:24 UTC Received: by mail-wg0-f47.google.com with SMTP id n12so12733123wgh.6 for ; Mon, 26 Jan 2015 21:25:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:content-type; bh=n18H4AMYHbq3eXlYvVivXnD3tUtUTp5/54NS+eVL9gA=; b=aP6y5Bmh7RDbjL4Fjlezj3Y01OVd85dUcxkUpNepqFk0djIBr0PCmwPuTbJsr61TDp HzukhVMcLeyJW3ygj17g4AA8k6497RYBTLGbUhe8BhX+VvBCQNFlWocj6eu7YsPcrWCd JcjEs02s0j1lrf036j0PBoCrrHMPfFemYzUbAXv7PH9UwlkA7o89fgryQi0vuO+0wLMr K49uYkY1mwiGSOtUuXrnn8T3qLY+3d7G6TSY1xNBCoq5pNSOxK4KbixlJ4dJmwATOs4D dObYFbQuefBzIU7PztOVrr5LSdB6+fE4gkzOKvN3tQ9NBWH/3M0SdzomKAWLZFmuVakf W5EA== X-Gm-Message-State: ALoCoQmOSrvR2ye4Xsi6zVH2HHOnJynCl7a9Y8vH4Z5sT/BO2van86S62vSLA/2ge7ilZVRI9FiFGCPtPL/2ojb6+Tg9qw8MwsFlZcPwKb7i+GuPwuh9Bpc7trRLe1PWCVZS4KXYftGGAkP/Q1a9ez3Z+2VVwEc6Ow== X-Received: by 10.194.219.68 with SMTP id pm4mr52483701wjc.71.1422336320629; Mon, 26 Jan 2015 21:25:20 -0800 (PST) X-Received: by 10.194.219.68 with SMTP id pm4mr52483694wjc.71.1422336320545; Mon, 26 Jan 2015 21:25:20 -0800 (PST) From: Khangelani Gama References: <203fb35202e040e00d0d3ed514414a2a@mail.gmail.com> <1422336077879-5835589.post@n5.nabble.com> In-Reply-To: <1422336077879-5835589.post@n5.nabble.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 thread-index: AQJA2paZjhO5A8LkQRP8LhzetuuWkwIvLifCm+C0mXA= Date: Tue, 27 Jan 2015 07:25:19 +0200 Message-ID: <7f2e8f98693a575fcebb1376116b27de@mail.gmail.com> Subject: Re: Postgres 9.2 - XML string functions ? To: David G Johnston , pgsql-admin@postgresql.org Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -4.2 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org 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