Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VoPTv-00080K-R8 for pgsql-sql@arkaria.postgresql.org; Thu, 05 Dec 2013 03:20:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VoPTv-0008OS-8x for pgsql-sql@arkaria.postgresql.org; Thu, 05 Dec 2013 03:20:03 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VoPTt-0008M8-JH for pgsql-sql@postgresql.org; Thu, 05 Dec 2013 03:20:01 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VoPTq-0000yJ-4w for pgsql-sql@postgresql.org; Thu, 05 Dec 2013 03:20:00 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1VoPTp-0002kn-Nc for pgsql-sql@postgresql.org; Wed, 04 Dec 2013 19:19:57 -0800 Date: Wed, 4 Dec 2013 19:19:57 -0800 (PST) From: David Johnston To: pgsql-sql@postgresql.org Message-ID: <1386213597725-5781776.post@n5.nabble.com> In-Reply-To: <1385763318819-5780918.post@n5.nabble.com> References: <1385763318819-5780918.post@n5.nabble.com> Subject: Re: XMLELEMENT produce a lower case of element name MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 3.7 (+++) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Andrey wrote > Hi, > > I have got a query like * > SELECT xmlelement(name FOO); * > >
>
> When I try it select the result is >
>
* > xmlelement >
> ------------ >
> * > >
>
> How can I save upper case in the element name? >
>
> SHOW Server_version 9.3.0 *First: * "Name"s in PostgreSQL are auto-lowercased when not enclosed in quotes: SELECT 'one' AS ONE and SELECT 'one' AS oNe and SELECT 'one' AS one all result in an output column with the name "one" (w/o quotes) To force case-preservation you enclose the name in double-quotes (though the stored name does not retain those quotes) SELECT 'one' AS "ONE" --> ONE SELECT 'one' AS "oNe" --> oNe *Second:* Type-casting forms (note there are other ways but they will not work in this situation) SELECT date '2013-10-01' AS actual_date The above casts the literal <2013-10-01> to a date datatype. SELECT xmlelement(name FOO) The above casts the literal to a "name" datatype - with a value of "foo" (w/o quotes) The explicit casting to name has the same behavior as all other names in PostgreSQL; specifically that it auto-lowercases the value if not enclosed in double-quotes. *Thus:* SELECT xmlelement(name "FOO") gives you an element with case preserved (and w/o quotes, as noted/shown above) /Aside>/ To be honest I'm somewhat surprised by this behavior as this is the only time I've encountered explicit "name" types and the casting of such in this way. This is indeed how this specific function works, and it is well documented - if you understand "names" and type-casting forms - but you are unlikely to encounter this type of syntax as you explore other areas of PostgreSQL. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/XMLELEMENT-produce-a-lower-case-of-element-name-tp5780918p5781776.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql