Quick Search:
 
 The Oracle XMLELEMENT Function      [Return To Index] Jump to:  

Term: XMLELEMENT

Definition:
In Oracle PL/SQL, XMLELEMENT is one of the commonly used functions in XML processing to define its elements. In short, it creates XML type elements from relational data. The XMLELEMENT function takes only the relational column as the necessary input.

Example Syntax:

XMLELEMENT (element name, value expression)

element name is the parent node name, while value expression contains the subnode information.

Example Usage:

A company uniquely identies its employee by their name and job. The SQL query below uses the XMLELEMENT function to create the XML fragment "Employee" out of its member column 'ENAME' and 'JOB'.

SELECT XMLELEMENT ("PSOUG",
XMLELEMENT ("Name", ename),
XMLELEMENT("Job", job))
FROM emp
/


XMLELEMENT("PSOUG",XMLELEMENT("ABC",ENAME),XMLELEMENT("XYZ",JOB))
-----------------------------------------------------------------
SMITHCLERK
ALLENSALESMAN
WARDSALESMAN
JONESMANAGER
MARTINSALESMAN
BLAKEMANAGER
CLARKMANAGER
SCOTTANALYST
KINGPRESIDENT
TURNERSALESMAN
ADAMSCLERK
JAMESCLERK
FORDANALYST
MILLERCLERK

14 rows selected.


Related Links:
 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org