Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle XMLELEMENT Function      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

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      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 158 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?