Monday, September 28, 2009

Cursor in query and xml

create table table_1 (countryid varchar2(10),country varchar2(20));

create table table_2 (cityid varchar2(10),city varchar2(20),countryid varchar2(10));


select cityid,cursor(city,countryid from table_2)
from table_2


select DBMS_XMLquery.GetXML('SELECT COUNTRYID, COUNTRY,
CURSOR (SELECT CITYID, CITY
FROM TABLE_2 T1
WHERE T1.COUNTRYID = T2.COUNTRYID) AS CITYNAME
FROM TABLE_1 T2',2) dd from dual;


SELECT countryid, country,
(SELECT cityid
FROM table_2 t1
AS cityname
FROM table_1 t2


select cityid,cursor(city,countryid
from table_2) as c
from table_2


exec Get_Xml_Schema('SELECT COUNTRYID, COUNTRY,
CURSOR (SELECT CITYID, CITY
FROM TABLE_2 T1
WHERE T1.COUNTRYID = T2.COUNTRYID) AS CITYNAME
FROM TABLE_1 T2')


select DBMS_XMLQuery.GetXML('select * from t1',2) from dual;

No comments: