agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: David Johnston <polobo@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: XMLELEMENT produce a lower case of element name
Date: Wed, 4 Dec 2013 19:19:57 -0800 (PST)
Message-ID: <1386213597725-5781776.post@n5.nabble.com> (raw)
In-Reply-To: <1385763318819-5780918.post@n5.nabble.com>
References: <1385763318819-5780918.post@n5.nabble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
Andrey wrote
> Hi,
>
> I have got a query like
*
> SELECT xmlelement(name FOO);
*
>
> </br>
> </br>
> When I try it select the result is
> </br>
> </br>
*
> xmlelement
> </br>
> ------------
> </br>
>
*
>
> </br>
> </br>
> How can I save upper case in the element name?
> </br>
> </br>
> 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 <FOO> 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-tp5780918p57...
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
Message-ID: <1386213597725-5781776.post@n5.nabble.com>
Permalink: ../1386213597725-5781776.post@n5.nabble.com/
Also on: postgresql.org/message-id/1386213597725-5781776.post@n5.nabble.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: polobo@yahoo.com
Subject: Re: XMLELEMENT produce a lower case of element name
In-Reply-To: <1386213597725-5781776.post@n5.nabble.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox