Creating a PL/SQL table based on XML file.

I have created two procedures to try and achieve the problem at hand.
It retrieves and displays the record from a DBMS_OUTPUT.PUT_LINE prospective as indicated in (1&2), but I am having difficulty loading these values into a PL/SQL table from the package labeled as (3).
All code compiles. (1&2) work together, (3) works by itself but will not populate the table, and I get no errors.
1.The first being the one that retrieves the XML file and parses it.
CREATE OR REPLACE procedure xml_main is
P XMLPARSER.Parser;
DOC CLOB;
v_xmldoc xmldom.DOMDocument;
v_out CLOB;
BEGIN
P := xmlparser.newParser;
xmlparser.setValidationMode(p, FALSE);
DOC := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<com.welligent.Student.BasicStudent.Create>
<ControlAreaSync messageCategory="com.welligent.Student" messageObject="BasicStudent" messageAction="Create" messageRelease="1.0" messagePriority="1" messageType="Sync">
<Sender>
<MessageId>
<SenderAppId>com.openii.SyncRouter</SenderAppId>
<ProducerId>a72af712-90ea-43be-b958-077a87a29bfb</ProducerId>
<MessageSeq>53</MessageSeq>
</MessageId>
<Authentication>
<AuthUserId>Router</AuthUserId>
</Authentication>
</Sender>
<Datetime>
<Year>2001</Year>
<Month>3</Month>
<Day>23</Day>
<Hour>13</Hour>
<Minute>47</Minute>
<Second>30</Second>
<SubSecond>223</SubSecond>
<Timezone>6:00-GMT</Timezone>
</Datetime>
</ControlAreaSync>
<DataArea>
<NewData>
<BasicStudent mealCode="" usBorn="Yes" migrant="No" workAbility="No" ellStatus="">
<StudentNumber>052589F201</StudentNumber>
<ExternalIdNumber>1234567890</ExternalIdNumber>
<StateIdNumber>123456</StateIdNumber>
<Name>
<LastName>Lopez</LastName>
<FirstName>Maria</FirstName>
<MiddleName>S</MiddleName>
</Name>
<Gender>Female</Gender>
<BirthDate>
<Month>1</Month>
<Day>1</Day>
<Year>1995</Year>
</BirthDate>
<Race>Hispanic</Race>
<Ethnicity>Hispanic</Ethnicity>
<PrimaryLanguage>English</PrimaryLanguage>
<HouseholdLanguage>Spanish</HouseholdLanguage>
<Address>
<Street>123 Any Street</Street>
<ApartmentNumber>12-D</ApartmentNumber>
<City>Los Angeles</City>
<County>Los Angeles</County>
<State>CA</State>
<ZipCode>90071</ZipCode>
</Address>
</BasicStudent>
</NewData>
</DataArea>
</com.welligent.Student.BasicStudent.Create>';
--v_out  := DOC;
SYS.XMLPARSER.PARSECLOB ( P, DOC );
v_xmldoc := SYS.XMLPARSER.getDocument(P);
--DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION);
--v_out := SYS.XMLPARSER.PARSECLOB ( P, DOC );
--SYS.XMLDOM.writetoCLOB(v_xmldoc, v_out);
--INSERT INTO TEST (TEST_COLUMN)
--VALUES(V_OUT);
--printElements(v_xmldoc);
printElementAttributes(v_xmldoc);
exception
when xmldom.INDEX_SIZE_ERR then
raise_application_error(-20120, 'Index Size error');
when xmldom.DOMSTRING_SIZE_ERR then
raise_application_error(-20120, 'String Size error');
when xmldom.HIERARCHY_REQUEST_ERR then
raise_application_error(-20120, 'Hierarchy request error');
when xmldom.WRONG_DOCUMENT_ERR then
raise_application_error(-20120, 'Wrong doc error');
when xmldom.INVALID_CHARACTER_ERR then
raise_application_error(-20120, 'Invalid Char error');
when xmldom.NO_DATA_ALLOWED_ERR then
raise_application_error(-20120, 'Nod data allowed error');
when xmldom.NO_MODIFICATION_ALLOWED_ERR then
raise_application_error(-20120, 'No mod allowed error');
when xmldom.NOT_FOUND_ERR then
raise_application_error(-20120, 'Not found error');
when xmldom.NOT_SUPPORTED_ERR then
raise_application_error(-20120, 'Not supported error');
when xmldom.INUSE_ATTRIBUTE_ERR then
raise_application_error(-20120, 'In use attr error');
END;
2. The second which displays the values from the .xml file I initialized above.
CREATE OR REPLACE procedure printElementAttributes(doc xmldom.DOMDocument) is
nl XMLDOM.DOMNODELIST;
len1           NUMBER;
len2 NUMBER;
n      XMLDOM.DOMNODE;
e      XMLDOM.DOMELEMENT;
nnm      XMLDOM.DOMNAMEDNODEMAP;
attrname VARCHAR2(100);
attrval VARCHAR2(100);
text_value VARCHAR2(100):=NULL;
n_child XMLDOM.DOMNODE;
BEGIN
-- get all elements
nl := XMLDOM.getElementsByTagName(doc, '*');
len1 := XMLDOM.getLength(nl);
-- loop through elements
FOR j in 0..len1-1 LOOP
n := XMLDOM.item(nl, j);
e := XMLDOM.makeElement(n);
DBMS_OUTPUT.PUT_LINE(xmldom.getTagName(e) || ':');
-- get all attributes of element
nnm := xmldom.getAttributes(n);
     n_child:=xmldom.getFirstChild(n);
text_value:=xmldom.getNodeValue(n_child);
dbms_output.put_line('val='||text_value);
IF (xmldom.isNull(nnm) = FALSE) THEN
len2 := xmldom.getLength(nnm);
          dbms_output.put_line('length='||len2);
-- loop through attributes
FOR i IN 0..len2-1 LOOP
n := xmldom.item(nnm, i);
attrname := xmldom.getNodeName(n);
attrval := xmldom.getNodeValue(n);
dbms_output.put(' ' || attrname || ' = ' || attrval);
END LOOP;
dbms_output.put_line('');
END IF;
END LOOP;
END printElementAttributes;
3. The package trying to insert into a PL/SQL table.
CREATE OR REPLACE PACKAGE BODY XMLSTUD2 AS
PROCEDURE STUDLOAD
IS
v_parser xmlparser.Parser;
v_doc xmldom.DOMDocument;
v_nl xmldom.DOMNodeList;
v_n xmldom.DOMNode;
DOC CLOB;
v_out CLOB;
n2 XMLDOM.DOMNODELIST;
TYPE stuxml_type IS TABLE OF STUDENTS%ROWTYPE;
s_tab stuxml_type := stuxml_type();
--l_sturec students%rowtype;
BEGIN
-- Create a parser.
v_parser := xmlparser.newParser;
xmlparser.setValidationMode(v_parser, FALSE);
DOC := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<com.welligent.Student.BasicStudent.Create>
<ControlAreaSync messageCategory="com.welligent.Student" messageObject="BasicStudent" messageAction="Create" messageRelease="1.0" messagePriority="1" messageType="Sync">
<Sender>
<MessageId>
<SenderAppId>com.openii.SyncRouter</SenderAppId>
<ProducerId>a72af712-90ea-43be-b958-077a87a29bfb</ProducerId>
<MessageSeq>53</MessageSeq>
</MessageId>
<Authentication>
<AuthUserId>Router</AuthUserId>
</Authentication>
</Sender>
<Datetime>
<Year>2001</Year>
<Month>3</Month>
<Day>23</Day>
<Hour>13</Hour>
<Minute>47</Minute>
<Second>30</Second>
<SubSecond>223</SubSecond>
<Timezone>6:00-GMT</Timezone>
</Datetime>
</ControlAreaSync>
<DataArea>
<NewData>
<BasicStudent mealCode="" usBorn="Yes" migrant="No" workAbility="No" ellStatus="">
<StudentNumber>052589F201</StudentNumber>
<ExternalIdNumber>1234567890</ExternalIdNumber>
<StateIdNumber>123456</StateIdNumber>
<Name>
<LastName>Lopez</LastName>
<FirstName>Maria</FirstName>
<MiddleName>S</MiddleName>
</Name>
<Gender>Female</Gender>
<BirthDate>
<Month>1</Month>
<Day>1</Day>
<Year>1995</Year>
</BirthDate>
<Race>Hispanic</Race>
<Ethnicity>Hispanic</Ethnicity>
<PrimaryLanguage>English</PrimaryLanguage>
<HouseholdLanguage>Spanish</HouseholdLanguage>
<Address>
<Street>123 Any Street</Street>
<ApartmentNumber>12-D</ApartmentNumber>
<City>Los Angeles</City>
<County>Los Angeles</County>
<State>CA</State>
<ZipCode>90071</ZipCode>
</Address>
</BasicStudent>
</NewData>
</DataArea>
</com.welligent.Student.BasicStudent.Create>';
-- Parse the document and create a new DOM document.
SYS.XMLPARSER.PARSECLOB ( v_parser, DOC );
v_doc := SYS.XMLPARSER.getDocument(v_parser);
-- Free resources associated with the Parser now it is no longer needed.
xmlparser.freeParser(v_parser);
-- Get a list of all the STUD nodes in the document using the XPATH syntax.
v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address');
dbms_output.put_line( 'New Stud processed on '||to_char(sysdate, 'YYYY-MON-DD'));
-- Loop through the list and create a new record in a tble collection
-- for each STUD record.
FOR stud IN 0 .. xmldom.getLength(v_nl) - 1 LOOP
v_n := xmldom.item(v_nl, stud);
s_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
     --s_tab(s_tab.last).STUDENT_ID :=xslprocessor.valueOf(v_n,'StudentNumber');
     --s_tab(s_tab.last).SSN :=xslprocessor.valueOf(v_n,'ExternalIdNumber');
     --s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'StateIdNumber');
     s_tab(s_tab.last).STUDENT_LAST_NAME :=xslprocessor.valueOf(v_n,'LastName');
     --dbms_output.put_line( s_tab(s_tab.last).STUDENT_LAST_NAME);
     s_tab(s_tab.last).STUDENT_FIRST_NAME :=xslprocessor.valueOf(v_n,'FirstName');
     --s_tab(s_tab.last).STUDENT_MI :=xslprocessor.valueOf(v_n,'MiddleName');
     --s_tab(s_tab.last).STUDENT_GENDER :=xslprocessor.valueOf(v_n,'Gender');
     --s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'Month');
     --s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'Day');
     --s_tab(s_tab.last).SHISID :=xslprocessor.valueOf(v_n,'Year');
     --s_tab(s_tab.last).STUDENT_RACE :=xslprocessor.valueOf(v_n,'Race');
     --s_tab(s_tab.last).STUDENT_ETHNIC :=xslprocessor.valueOf(v_n,'Ethnicity');
     --s_tab(s_tab.last).STUDENT_PRI_LANG :=xslprocessor.valueOf(v_n,'PrimaryLanguage');
     --s_tab(s_tab.last).STUDENT_SEC_LANG :=xslprocessor.valueOf(v_n,'HouseholdLanguage');
     --s_tab(s_tab.last).STUDENT_STREET :=xslprocessor.valueOf(v_n,'Street');
     --s_tab(s_tab.last).STUDENT_APART_NO :=xslprocessor.valueOf(v_n,'ApartmentNumber');
     --s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'City'); 
     --s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'County');
     --s_tab(s_tab.last).STUDENT_STATE :=xslprocessor.valueOf(v_n,'State');
     --s_tab(s_tab.last).STUDENT_ZIP :=xslprocessor.valueOf(v_n,'ZipCode');
END LOOP;
FOR stud IN s_tab.first..s_tab.last LOOP
dbms_output.put_line( s_tab(s_tab.last).STUDENT_LAST_NAME);
INSERT INTO STUDENTS (
SHISID, SSN, DOE_SCHOOL_NUMBER,
PATIENT_TYPE, TEACHER, HOMEROOM,
STUDENT_LAST_NAME, STUDENT_FIRST_NAME, STUDENT_MI,
STUDENT_DOB, STUDENT_BIRTH_CERT, STUDENT_COMM,
STUDENT_MUSA, STUDENT_FAMSIZE, STUDENT_FAMINCOME,
STUDENT_UNINSURED, STUDENT_LUNCH, STUDENT_ZIP,
STUDENT_STATE, STUDENT_COUNTY, STUDENT_STREET,
STUDENT_APART_NO, STUDENT_PHONE, STUDENT_H2O_TYPE,
STUDENT_WASTE_TRT, STUDENT_HOME_SET, STUDENT_NONHOME_SET,
STUDENT_GENDER, STUDENT_RACE, STUDENT_ETHNIC,
STUDENT_PRI_LANG, STUDENT_SEC_LANG, STUDENT_ATRISK,
EMER_COND_MEMO, ASSIST_DEVICE_TYPE, SCHOOL_ENTER_AGE,
STUDENT_CURR_GRADE, S504_ELIG_DATE, S504_DEV_DATE,
S504_REV_DATE, STUDENT_504, STUDENT_IEP,
IEP_EXP_DATE, GRAD_CLASS, TYPE_DIPLOMA,
GRADE_RETAIN, LIT_PASS_TEST_MATH, LIT_PASS_DATE_MATH,
LIT_PASS_TEST_WRITE, LIT_PASS_DATE_WRITE, LIT_PASS_TEST_READ,
LIT_PASS_DATE_READ, SPEC_ED_ELIG, SPEC_ED_CODE,
TRANSPORT_CODE, TRANSPORT_NO, PRIME_HANDICAP,
PRIME_HANDICAP_PERCENT, PRIME_HANDI_MANAGER, FIRST_ADD_HANDI,
FIRST_ADD_HANDICAP_PERCENT, FIRST_ADD_HANDI_504, FIRST_ADD_HANDI_504_DATE,
SECOND_ADD_HANDI, SECOND_ADD_HANDICAP_PERCENT, MED_EXTERNAL_NAME,
INS_TYPE, INS_PRI, INS_NAME,
INS_MEDICAID_NO, ELIGDATE, INS_PRIV_INSURANCE,
INS_APPR_BILL, INS_APPR_DATE, INS_PARENT_APPR,
INS_POL_NAME, INS_POL_NO, INS_CARRIER_NO,
INS_CARRIER_NAME, INS_CARRIER_RELATE, INS_AFFECT_DATE,
INS_COPAY_OV, INS_COPAY_RX, INS_COPAY_AMBUL,
INS_COPAY_EMER, INS_COPAY_OUTPAT, STUDENT_INACTIVE,
PHYS_ID, ENCOUNTERNUM, USERID,
MODDATE, STUDENT_ID, S504_DISABILITY,
CHAPTER1, WELLNESS_ENROLL, SCHOOL_OF_RESIDENCE,
INITIAL_IEP_DATE, CALENDAR_TRACK, USA_BORN,
ALT_ID, FUTURE_SCHOOL, IEP_LAST_MEETING,
IEP_LAST_SETTING, IEP_LAST_REFER_EVAL, THIRD_ADD_HANDI,
LEP, GIFTED, IEP_EXIT_REASON,
CASE_MANAGER_ID, INTAKE_NOTES, CALLER_PHONE,
CALL_DATE, CALLER_RELATIONSHIP, CALLER_NAME,
BUSINESS_PHONE, FAX, EMAIL,
HIGHEST_EDUCATION, INTAKE_DATE, SERVICE_COORDINATOR,
DISCHARGE_DATE, DISCHARGE_REASON, DISCHARGE_NOTES,
INTAKE_BY, INTAKE_STATUS, IEP_LAST_SERVED_DATE,
IEP_APC_DATE, IEP_EXIT_DATE, ADDRESS2,
LEGAL_STATUS, RELIGION, EMPLOYMENT_STATUS,
TARG_POP_GROUP1, TARG_POP_GROUP2, MARITAL_STATUS,
THIRD_ADD_HANDI_PERCENT, LAST_INTERFACE_DATE, SERVICE_PLAN_TYPE,
CURRENT_JURISDICTION, FIPS, BIRTH_PLACE_JURISDICTION,
BIRTH_PLACE_HOSPITAL, BIRTH_PLACE_STATE, BIRTH_PLACE_COUNTRY,
OTHER_CLIENT_NAME, SIBLINGS_WITH_SERVICES, PERM_SHARE_INFORMATION,
PERM_VERIFY_INSURANCE, REFERRING_AGENCY, REFERRING_INDIVIDUAL,
AUTOMATIC_ELIGIBILITY, INTAKE_IEP_ID, FUTURE_SCHOOL2,
FUTURE_SCHOOL3, TRANSLATOR_NEEDED, TOTAL_CHILDREN_IN_HOME,
REFERRED_BY, FAMILY_ID, SCREENING_CONSENT_FLAG,
PICTURE_FILE, DUAL_ENROLLED, DOE_SCHOOL_NUMBER2)
VALUES (123456789012, null,null ,
null,null,null ,s_tab(stud).STUDENT_LAST_NAME
, s_tab(stud).STUDENT_LAST_NAME,null ,
null ,null ,null ,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null ,null , null,
null, null,null );
END LOOP;
COMMIT;
-- Free any resources associated with the document now it
-- is no longer needed.
xmldom.freeDocument(v_doc);
END STUDLOAD;
END XMLSTUD2;
/

Hi
I have created a PLSQL package based Oracle Portal
form. This is created a s a databse provider. I have
following questions to check :
1. How to capture return values from the package and
display different messages on success or failure ?
- http://download.oracle.com/docs/cd/B14099_19/portal.1014/b14135/pdg_portletbuilder.htm#BABBAFGI
Step 16
2. How to return to blank form by intializing already
entered values after successfuly process of the form
data.
- http://download.oracle.com/docs/cd/B14099_19/portal.1014/b14135/pdg_portletbuilder.htm#BABGBCHH
thanks
Manjith

Similar Messages

  • Build a table based on XML data set with Spry

    Hi there,
    I'm new to spry technology therefore forgive any basic question of mine.
    I'm trying to fill content in a table based on XML data set values but nothing is shown :-(
    here is my code.... any suggestion? pls tell me where I'm wrong.
    Thank you in advance
    <script src="SpryAssets/xpath.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryData.js" type="text/javascript"></script>
    <script type="text/javascript">
    var uscite = new Spry.Data.XMLDataSet("data/Calendario 2011.xml", "csv_data_records/record", {sortOnLoad: "Date", sortOrderOnLoad: "ascending"});
    uscite.setColumnType("Date", "date");
    uscite.setColumnType("km", "number");
    </script>
    <div class="RankContainer" id="UsciteDiv" spry:region="uscite" >
              <table width="100%" border="0" class="RankTable">
                <tr>
                  <th width="10%" scope="col" spry:sort="Date">Data</th>
                  <th width="20%" scope="col">Destinazione</th>
                  <th width="5%" scope="col">KM</th>
                  <th width="35%" scope="col">Percorso</th>
                  <th width="30%" scope="col">Breve</th>
                 <!-- <th width="15%" scope="col">Mappa</th>-->
                </tr>
                <tr>
                   <script type="text/javascript">
           var rows = uscite.getData();
        for (var i = 0; i < rows.length; i++)
         if (rows[i]["Mappa"].startsWith("/"))
          rowContent = "<td> si </td>";
         else
              rowContent = "<td> no </td>";
         document.write("<td>{Date}</td>");
         document.write("<td>"+rowContent+"</td>");
         document.write("<td>{km}</td>");
         document.write("<td>{Percorso}</td>");
         document.write("<td>{Breve}</td>");
          </script>
               </tr>
              </table>
           </div>

    Sure this is how it should work (except that no anchor tag shall be present for Destinazione whereas Mappa has no real value in)
    http://www.gsc-borsano.it/_Calendario%202011.html
    and this is the non working page
    http://www.gsc-borsano.it/_v2Calendario%202011.html
    Thanks

  • Inserting data from  a table  to an XML file

    I want to insert the values from this xml file emp.xml into a table Employees :
    <EMPLOYEES>
    <EMP>
    <EMPNO>7369</EMPNO>
    <ENAME>SMITH</ENAME>
    <JOB>CLERK</JOB>
    <HIREDATE>17-DEC-80</HIREDATE>
    <SAL>800</SAL>
    </EMP>
    <EMP>
    <EMPNO>7499</EMPNO>
    <ENAME>ALLEN</ENAME>
    <JOB>SALESMAN</JOB>
    <HIREDATE>20-FEB-81</HIREDATE>
    <SAL>1600</SAL>
    <COMM>300</COMM>
    </EMP>
    <EMP>
    </EMPLOYEES>
    and here is my Employee table in Oracle 9i database
    SQL> DESC EMPLOYEE;
    Name Null? Type
    EMPNO NUMBER
    EMPNAME VARCHAR2(10)
    JOB VARCHAR2(10)
    HIREDATE DATE
    SAL NUMBER
    After getting help from the members i was able to do the insert of data from the xml file to the table..how to do the insert of data from the table to the xml file.
    Regards,
    Renu

    Hello michaels , thank you for the solution, still i am having some problems
    Here is what i have done :
    1.
    SQL> CREATE DIRECTORY my_table_dir AS 'E:\table_files'
    2 ;
    Directory created.
    2.
    SQL> select * from myemp;
    ENAME
    SMITH
    ALLEN
    3.
    This is the content of the existing xml file saved in the directory E:\table_files as emp.xml
    <EMPLOYEES>
    <EMP>JIM</EMP>
    <EMP>RICK</EMP>
    </EMPLOYEES>
    4.
    Now i executed this code :
    declare
    emp_xml xmltype;
    begin
    select sys_xmlagg (column_value, sys.xmlformat ('EMPLOYEES')) emp_xml
    into emp_xml
    from table (xmlsequence (cursor (select *
    from myemp
    where ename in ('SMITH', 'ALLEN')),
    sys.xmlformat ('EMP')
    dbms_xslprocessor.clob2file (emp_xml.getclobval (), 'E:\table_files', 'emp.xml');
    end;
    And the Error i got is :
    declare
    ERROR at line 1:
    ORA-29280: invalid directory path
    ORA-06512: at "SYS.UTL_FILE", line 18
    ORA-06512: at "SYS.UTL_FILE", line 424
    ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 46
    ORA-06512: at line 12

  • Exporting data from database tables to a XML file

    Hi,
    We want to export data from Oracle database tables to an XML
    file. What tool can we use for this purpose, and how do we go
    about it ?
    Can we extract data only from an Oracle8 database, or can we
    extract data from Oracle7.3 databases too ?
    Any help in this regard would be appreciated.
    Thanks
    Dipanjan
    null

    Dipanjan (guest) wrote:
    : Hi,
    : We want to export data from Oracle database tables to an XML
    : file. What tool can we use for this purpose, and how do we go
    : about it ?
    : Can we extract data only from an Oracle8 database, or can we
    : extract data from Oracle7.3 databases too ?
    : Any help in this regard would be appreciated.
    : Thanks
    : Dipanjan
    Start by downloading the XML SQL Utility and make sure you have
    the approriate JDBC 1.1 drivers installed for your database.
    There are samples which will get you going included in the
    archive.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • Internal table data to XML file.

    Hi All,
    May I know how can we convert the internal table data to xml file?
    Regards
    Ramesh.

    Re: Convert XML to internal Table
       Go through the link..u should be able to solve the problem..

  • How to export table contents in xml file format through SQL queries

    hi,
    i need to export the table data in to xml file format. i got it through the GUI what they given.
    i'm using Oracle 10g XE.
    but i need to send the table name from Java programs. so, how to call the export commands from programming languages through. is there any sql commands to export the table contents in xml format.
    and one more problem is i created each transaction in two tables. for example if we have a transaction 'sales' , that will be saved in db as
    sales1 table and sales2 table. here i maintained and ID field in sales1 as PK. and id as FK in sales2.
    i get the combined data with this query,
    select * from sales1 s1, sales2 s2 where s1.id=s2.id order by s1.id;
    it given all the records, but i'm getting two ID fields (one from each table). how to avoid this. here i dont know how many fields will be there in each table. that will be known at runtime only.
    the static information is sales1 have one ID field with PK and sales2 will have one ID filed with FK.
    i need ur valuable suggestions.
    regards
    pavan.

    You can use DBMS_XMLGEN.getXML('your Query') for generating data in tables to XML format and you can use DBMS_XMLGEN.SETROWSETTAG to change the parent element name other wise it will give rowset as well as DBMS_XMLGEN.SETROWTAG for row name.
    Check this otherwise XMLELEMENT and XMLFOREST function are also there to convert data in XML format.

  • Should I create table before insert xml files

    Hi,,,
    I am developing a application that insert various xml files
    into oracle8i dbms..
    So, I am studying Oracle XML SQL Utility and I understood that
    I should create appropriate tables suit for the XML files..
    (tag <--> table column name...) before insert them to the dbms.
    But In my project, the xml file is not fixed.
    And new XML files (new tag name, new DTD required) can be
    generated by the end user.
    Is there any solution??? create table suit for xml
    automatically..
    And...
    How can I create table to insert the following xml file..
    <univ>
    <college name="engineering">
    <department name="electronic">
    <student id="11">
    <math> 100 </math>
    <english> 90 </english>
    </student>
    </department>
    </college>
    <college name="law">
    <department name="law">
    <student id="55">
    <math> 90 </math>
    <english> 100 </english>
    </student>
    </department>
    </college>
    </univ>
    null

    Hi,
    One more thing is that, you can use XSLT to transform any
    document that you get into a canonical representation that u can
    then use to put into the database.
    For example, if the user gave,
    <univ>
    <college name="eng">
    <...>
    </college>
    </univ>
    you can then use XSLT to transform it into all-element form,
    such as,
    <univ>
    <college>
    <name>engineering</name>
    </college>
    </univ>
    and use OracleXMLSave to put it into the database. Also if you
    have structured XML elements you can map them nicely into object
    types in Oracle 8.
    Regarding creating the table, for the exampe that you showed,
    you can create an object type column for storing it,example,
    CREATE TYPE college_type AS OBJECT
    name VARCHAR2(50),
    dept department_type,
    CREATE TYPE department_type AS OBJECT
    name VARCHAR2(40),
    CREATE TABLE univ_tab ( college college_type);
    You could have also created object views over multiple
    relational tables and achieved the same.
    Thx
    The OracleXML team.
    Oracle XML Team wrote:
    : Instead of using attributes to store your data, use elements.
    : For example:
    : <univ>
    : <college>
    : <collname>engineering</collname>
    : <department>
    : <deptname>electronic</deptname>
    : <student>
    : <id>11</id>
    : <math>100</math>
    : <english>90</english>
    : </student>
    : </college>
    : </univ>
    : Oracle XML Team
    : http://technet.oracle.com
    : Oracle Technology Network
    : Chong, Ho-chul (guest) wrote:
    : : Hi,,,
    : : I am developing a application that insert various xml files
    : : into oracle8i dbms..
    : : So, I am studying Oracle XML SQL Utility and I understood
    : that
    : : I should create appropriate tables suit for the XML files..
    : : (tag <--> table column name...) before insert them to the
    dbms.
    : : But In my project, the xml file is not fixed.
    : : And new XML files (new tag name, new DTD required) can be
    : : generated by the end user.
    : : Is there any solution??? create table suit for xml
    : : automatically..
    : : And...
    : : How can I create table to insert the following xml file..
    : : <univ>
    : : <college name="engineering">
    : : <department name="electronic">
    : : <student id="11">
    : : <math> 100 </math>
    : : <english> 90 </english>
    : : </student>
    : : </department>
    : : </college>
    : : <college name="law">
    : : <department name="law">
    : : <student id="55">
    : : <math> 90 </math>
    : : <english> 100 </english>
    : : </student>
    : : </department>
    : : </college>
    : : </univ>
    Oracle Technology Network
    http://technet.oracle.com
    null

  • Create controls dynamically based on XML file

    Hi All,
    I am very new to Flex environment. I am trying to integrate FLEX with ASP.net for better UI interfacing.
    May I know if is it possible to draw fields (Text boxes, option buttons, etc) on the Flex dynamically using a XML file at runtime.
    What my expectation is, if I have an XML file with the filed names and type, can the Flex draw them on the front end UI?
    Please  let me know your thoughts.
    Naveen

    Is there possible to have an portlet that can be enlarged?Yes. You can maximise a portlet
    And is there possible if I have a .php file, and then I want to create a portlet based on that .php fileNot directly.
    If you are going to run the PHP file in its own machine then you could use a browser or clipper portlet. If you want to run the PHP file on the JVM itself, I believe there are some commercial products that let you do this (then its equivalent to a JavaServlet). This could then be included by any dummy JSP and you could use a plain jsp portlet . however you wqould have to be careful how you generate links within the PHP file (because you'd have to mimic the way BEA tags behave) .
    never tried this and if you have few PHP pages then you could probably rewrite to java.

  • How to get the column name and table name from xml file

    I have one XML file, I generated xsd file from that xml file but the problem is i dont know table name and column name. So my question is how can I retrieve the data from that xml file?

    Here's an example using binary XML storage (instead of Object-Relational storage as described in the article).
    begin
      dbms_xmlschema.registerSchema(
        schemaURL       => 'my_schema.xsd'
      , schemaDoc       => xmltype(bfilename('TEST_DIR','my_schema.xsd'), nls_charset_id('AL32UTF8'))
      , local           => true
      , genTypes        => false
      , genTables       => true
      , enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_CONTENTS
      , options         => dbms_xmlschema.REGISTER_BINARYXML
    end;
    genTables => true : means that a default schema-based XMLType table will be created during registration.
    enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_CONTENTS : indicates that a repository resource conforming to the schema will be automatically stored in the default table.
    If the schema is not annotated, the name of the default table is system-generated but derived from the root element name :
    SQL> select table_name
      2  from user_xml_tables
      3  where xmlschema = 'my_schema.xsd'
      4  and element_name = 'employee';
    TABLE_NAME
    employee1121_TAB
    (warning : the name is case-sensitive)
    To annotate the schema and control the naming, modify the content to :
    <?xml version="1.0" encoding="UTF-8" ?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb">
      <xs:element name="employee" xdb:defaultTable="EMPLOYEE_XML">
        <xs:complexType>
    Next step : create a resource, or just directly insert an XML document into the table.
    Example of creating a resource :
    declare
      res  boolean;
      doc  xmltype := xmltype(
    '<employee>
      <details>
        <emp_id>1</emp_id>
        <emp_name>SMITH</emp_name>
        <emp_age>40</emp_age>
        <emp_dept>10</emp_dept>
      </details>
    </employee>'
    begin
      res := dbms_xdb.CreateResource(
               abspath   => '/public/test.xml'
             , data      => doc
             , schemaurl => 'my_schema.xsd'
             , elem      => 'employee'
    end;
    The resource has to be schema-based so that the default storage mechanism is triggered.
    It could also be achieved if the document possesses an xsi:noNamespaceSchemaLocation attribute :
    SQL> declare
      2 
      3    res  boolean;
      4    doc  xmltype := xmltype(
      5  '<employee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      6             xsi:noNamespaceSchemaLocation="my_schema.xsd">
      7    <details>
      8      <emp_id>1</emp_id>
      9      <emp_name>SMITH</emp_name>
    10      <emp_age>40</emp_age>
    11      <emp_dept>10</emp_dept>
    12    </details>
    13   </employee>'
    14   );
    15 
    16  begin
    17    res := dbms_xdb.CreateResource(
    18             abspath   => '/public/test.xml'
    19           , data      => doc
    20           );
    21  end;
    22  /
    PL/SQL procedure successfully completed
    SQL> set long 5000
    SQL> select * from "employee1121_TAB";
    SYS_NC_ROWINFO$
    <employee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceS
      <details>
        <emp_id>1</emp_id>
        <emp_name>SMITH</emp_name>
        <emp_age>40</emp_age>
        <emp_dept>10</emp_dept>
      </details>
    </employee>
    Then use XMLTABLE to shred the XML into relational format :
    SQL> select x.*
      2  from "employee1121_TAB" t
      3     , xmltable('/employee/details'
      4         passing t.object_value
      5         columns emp_id   integer      path 'emp_id'
      6               , emp_name varchar2(30) path 'emp_name'
      7       ) x
      8  ;
                                     EMP_ID EMP_NAME
                                          1 SMITH

  • Need to insert values into a table from a XML file

    Hi,
    I'm an Oracle 9i/10g DBA with quite a few years experience, but I'm new to XML and dealing with it in database terms. I've been given a project that entails pulling XML values out of a file (or 100's of them) and storing them in the database so that they are searchable by end-users. The project is classified as secret so I'm unable to upload the specific XML or any info relating to the structire of the XML or the table I will use to insert the values into - sorry!! So, I've created an XML file with a similar structure to help people understand my predicament.
    The end-users only need to search on a subset of the total amount of columns from the table I'll insert data into, although the XML file has a lot more, so I dont need to store the other values - but I will need to store the name of the XML file (or a pointer to it so I know what XML file a particular set of values belong to) in another column of the table along with its associated values.
    I've been using the XMLTABLE function with some degree of success, although I had better succes using the XMLSEQUENCE function. However, I found out this is deprecated in 10g and replaced with XMLTABLE, so I guess it's better if I use this in case we ever need to upgrade to 11g.
    The main problem I've been having is that some elements in the XML files have multiple values for the one record when all the other records are the same. In terms of storing this in the database, I guess it would mean inserting multiple rows in the table for each element where the value differs. Here is a dumbed down XML file similar to what I've got along with the other SQL I've used:
    +<?xml version="1.0" encoding="UTF-8"?>+
    +<House>+
    +<Warehouse>+
    +<WarehouseId>1</WarehouseId>+
    +<WarehouseName>+
    +<Town>Southlake</Town>+
    +<State>Texas</State>+
    +</WarehouseName>+
    +<Building>Owned</Building>+
    +<Area>25000</Area>+
    +<Docks>2</Docks>+
    +<DockType>Rear load</DockType>+
    +<WaterAccess>true</WaterAccess>+
    +<RailAccess>N</RailAccess>+
    +<Parking>Street</Parking>+
    +<VClearance>10</VClearance>+
    +</Warehouse>+
    +<Warehouse>+
    +<WarehouseId>2</WarehouseId>+
    +<WarehouseName>+
    +<Town>Poole</Town>+
    +<State>Dorset</State>+
    +</WarehouseName>+
    +<WarehouseName>+
    +<Town>Solihull</Town>+
    +<County>West Midlands</State>+
    +</WarehouseName>+
    +<Building>Owned</Building>+
    +<Area>40000</Area>+
    +<Docks>5</Docks>+
    +<DockType>Rear load</DockType>+
    +<WaterAccess>true</WaterAccess>+
    +<RailAccess>N</RailAccess>+
    +<Parking>Bay</Parking>+
    +<VClearance>10</VClearance>+
    +</Warehouse>+
    +<Warehouse>+
    +<WarehouseId>3</WarehouseId>+
    +<WarehouseName>+
    +<Town>Fleet</Town>+
    +<County>Hampshire</County>+
    +</WarehouseName>+
    +<Building>Owned</Building>+
    +<Area>10000</Area>+
    +<Docks>1</Docks>+
    +<DockType>Side load</DockType>+
    +<WaterAccess>false</WaterAccess>+
    +<RailAccess>N</RailAccess>+
    +<Parking>Bay</Parking>+
    +<VClearance>20</VClearance>+
    +</Warehouse>+
    +</House>+
    CREATE TABLE xmltest OF XMLTYPE;
    INSERT INTO xmltest
    VALUES(xmltype(bfilename('XML_DIR', 'test.xml'), nls_charset_id('AL32UTF8')));
    Consequently, I need to...
    1) Retrieve the results from the XML file for all 3 warehouses where multiple values for the same sub-element are shown as 2 rowsthe result set. (I am guessing there will be 4 rows returned as warehouse sub-2 has 2 different elements for <WarehouseName>.
    2) Build a case statement into the query so that regardless of the sub-element name (i.e State or County), it is returned into the 1 column, for instance County.
    So, if I run a query similar to the following...
    select y.WarehouseId, y.Town, y.County, y.Area
    from xmltest x, xmltable('/House/Warehouse' .......
    I would like to get results back like this...
    ID Town County Area
    1 Southlake Texas 25000
    2 Poole Dorset 40000
    2 Solihull West Midlands 40000
    3 Fleet hampshire 10000
    Sorry for the non-formatting but I hope this all makessense to someone out there with what I'm trying to do.
    I appreciate any help whatsoever because, as i said before, I'm totally new to XML and trying to read the vast amount of information there is out there on XML is all a bit daunting.
    Many thanks in advance,
    Shaun.

    Hi again,
    Thanks for keeping the post open for me. I've had a look at the post illustrating the XFileHandler package, and tried to alter it to make it fit with my XML files. To help explain things, my XML file looks like this:
    <?xml version="1.0"?>
    <!DOCTYPE  CMF_Doc SYSTEM "CMF_Doc.dtd">
    <House>
        <Warehouse>
        <WarehouseId>1</WarehouseId>
        <WarehouseName>
           <Town>Southlake</Town>
           <State>Texas</State>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>25000</Area>
        <Docks>2</Docks>
        <DockType>Rear load</DockType>
        <WaterAccess>true</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Street</Parking>
        <VClearance>10</VClearance>
      </Warehouse>
      <Warehouse>House
        <WarehouseId>2</WarehouseId>
        <WarehouseName>
           <Town>Poole</Town>
           <State>Dorset</State>
        </WarehouseName>
        <WarehouseName>
           <Town>Solihull</Town>
           <County>West Midlands</County>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>40000</Area>
        <Docks>5</Docks>
        <DockType>Rear load</DockType>
        <WaterAccess>true</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Bay</Parking>
        <VClearance>10</VClearance>
      </Warehouse>
      <Warehouse>
        <WarehouseId>3</WarehouseId>
        <WarehouseName>
           <Town>Fleet</Town>
           <County>Hampshire</County>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>10000</Area>
        <Docks>1</Docks>
        <DockType>Side load</DockType>
        <WaterAccess>false</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Bay</Parking>
        <VClearance>20</VClearance>
      </Warehouse>
    </House>
    <?xml version="1.0" encoding="UTF-8"?>
    <House>
        <Warehouse>
        <WarehouseId>4</WarehouseId>
        <WarehouseName>
           <Town>Dallas</Town>
           <State>Texas</State>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>25000</Area>
        <Docks>2</Docks>
        <DockType>Rear load</DockType>
        <WaterAccess>true</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Street</Parking>
        <VClearance>10</VClearance>
      </Warehouse>
      <Warehouse>
        <WarehouseId>5</WarehouseId>
        <WarehouseName>
           <Town>Dorchester</Town>
           <State>Dorset</State>
        </WarehouseName>
        <WarehouseName>
           <Town>Solihull</Town>
           <County>West Midlands</County>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>40000</Area>
        <Docks>5</Docks>
        <DockType>Rear load</DockType>
        <WaterAccess>true</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Bay</Parking>
        <VClearance>10</VClearance>
      </Warehouse>
      <Warehouse>
        <WarehouseId>6</WarehouseId>
        <WarehouseName>
           <Town>Farnborough</Town>
           <County>Hampshire</County>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>10000</Area>
        <Docks>1</Docks>
        <DockType>Side load</DockType>
        <WaterAccess>false</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Bay</Parking>
        <VClearance>20</VClearance>
      </Warehouse>
    </House>
    <?xml version="1.0" encoding="UTF-8"?>
    <House>
        <Warehouse>
        <WarehouseId>7</WarehouseId>
        <WarehouseName>
           <Town>Southlake</Town>
           <State>Texas</State>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>25000</Area>
        <Docks>2</Docks>
        <DockType>Rear load</DockType>
        <WaterAccess>true</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Street</Parking>
        <VClearance>10</VClearance>
      </Warehouse>
      <Warehouse>
        <WarehouseId>8</WarehouseId>
        <WarehouseName>
           <Town>Bournemouth</Town>
           <State>Dorset</State>
        </WarehouseName>
        <WarehouseName>
           <Town>Shirley</Town>
           <County>West Midlands</County>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>30000</Area>
        <Docks>5</Docks>
        <DockType>Rear load</DockType>
        <WaterAccess>true</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Bay</Parking>
        <VClearance>10</VClearance>
      </Warehouse>
      <Warehouse>
        <WarehouseId>9</WarehouseId>
        <WarehouseName>
           <Town>Clapham</Town>
           <County>London</County>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>10000</Area>
        <Docks>1</Docks>
        <DockType>Side load</DockType>
        <WaterAccess>false</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Bay</Parking>
        <VClearance>20</VClearance>
      </Warehouse>
    </House>And the XFilehandler package looks like this (I'm just trying to do a simple select only on WarehouseId & WaterAccess for the time being to keep things simple):
    create or replace package XFileHandler as
      TYPE TRECORD IS RECORD (
        WID     NUMBER(2)
      , WACCESS VARCHAR2(5)
      type TRecordTable is table of TRecord;
      function getRows (p_directory in varchar2, p_filename in varchar2) return TRecordTable pipelined;
    end;
    create or replace package body XFileHandler is
      function getRows (p_directory in varchar2, p_filename in varchar2)
       return TRecordTable pipelined
      is
        nb_rec          number := 1;
        tmp_xml        clob;
        tmp_file         clob;
        rec               TRecord;
      begin
        DBMS_LOB.CREATETEMPORARY(TMP_FILE, TRUE);
        tmp_file := dbms_xslprocessor.read2clob(p_directory, p_filename);
        LOOP
          tmp_xml := regexp_substr(tmp_file, '<\?xml[^?]+\?>\s*<([^>]+)>.*?</\1>', 1, nb_rec, 'n');
          exit when length(tmp_xml) = 0;
          --dbms_output.put_line(tmp_rec);
          nb_rec := nb_rec + 1;
        select y.WID, y.WACCESS
        into rec.WID, rec.WACCESS
        from xmltable('/House' passing xmltype(tmp_xml)
                      columns WID NUMBER(2) PATH 'Warehouse/WarehouseId',
                                  WACCESS VARCHAR2(5) PATH 'WaterAccess') y;
          pipe row ( rec );
        end loop;
        dbms_lob.freetemporary(tmp_file);
        return;
      end;
    end;Now, when I run the query:
    select * from table(XFileHandler.getRows('XML_DIR', 'XFileHandler_test.xml'));I get the error: ORA-00600: internal error code, arguments: [17285], [0x5CFE8DC8], [4], [0x45ABE1C8], [], [], [], []
    I had a look in the dump file for anything obvious, but nothing really stands out. Is there anything obvious in my code that I'm missing or something else which you may think could be causing this error, e.g in the regular expression regexp_substr?
    Many thanks,
    Shaun.

  • PL/SQL procedure to process XML file

    I am just starting to work on xml, and we are using PL/SQL stored procedures to process xml file. I did find the sample code in the package (family.sql). This sample print out all element names and attributes. My questions are :
    (1) I tried to modify the code to print out the element values (or Node values). Here is the code:
    -- get all elements and values
    nl := xmlparser.getElementsByTagName(doc, '*');
    len := xmlparser.getLength(nl);
    -- loop through elements
    for i in 0..len-1 loop
    n := xmlparser.item(nl, i);
    dbms_output.put_line('NodeName: ' &#0124; &#0124; xmlparser.getNodeName(n) &#0124; &#0124; ' ');
    dbms_output.put_line('NodeValue: ' &#0124; &#0124; xmlparser.getNodeValue(n) &#0124; &#0124; ' ');
    end loop;
    However, it did not print out the values, although it did print out the name. what's wrong with it? how can I get the value?
    (2) I have the following xml file:
    <?xml version="1.0"?>
    <profile>
    <id>1</id>
    <name>Company</name>
    <des>master profile</desc>
    <subprofile>
    <subid>1</subid>
    <subname>group1</subname>
    <subdesc>group profile</subdesc>
    </subprofile>
    </profile>
    now, I'd like to print out all the children of the <subprofile> node, that is <subid>, <subname> and <subdesc>. Here is my code:
    -- get subprofile nodelist
    qnlist := xmlparser.getElementsByTagName(doc, 'subprofile');
    -- get length of the nodelist
    len := xmlparser.getLength(qnlist);
    -- loop through elements
    for i in 0..len-1 loop
    qnode := xmlparser.item(qnlist, i);
    qnnode := xmlparser.getFirstChild(qnode);
    qnchild := xmlparser.getFirstChild(qnnode);
    dbms_output.put_line(xmlparser.getNodeName(qnnode));
    dbms_output.put_line(xmlparser.getNodeValue(qnchild));
    LOOP
    if (xmlparser.isNULL(xmlparser.getNextSibling(qnnode))) then exit;
    END IF;
    qnnode := xmlparser.getNextSibling(qnnode);
    qnchild := xmlparser.getFirstChild(qnnode);
    dbms_output.put_line(xmlparser.getNodeName(qnnode));
    dbms_output.put_line(xmlparser.getNodeValue(qnchild));
    END LOOP;
    end loop;
    when I execute the procedure, I get the following output:
    #text
    I am not sure what's wrong with it. Basically, I didn't know the procedure to traverse the tree since here it's a little different from OO programming. Could someone give a sample code which demonstrate the procedure which can get a specific element's name and values? (for my exapmle, the name and value of the <subname>, or <subid>, <subdesc>).
    Also, is there a way to insert a part of xml file into a DB table? in my case, insert the subprofile into a table. I know the xmlgen package has a procedure to insert a xml file into a table, but not a part of xml. And can I insert a xml file into several tables instead of one table, using xmlgen package?
    looking forward to hearing from you. any suggestion and sample code would be helpful. thank you very much.
    null

    I sloved my first question: to get the Nodevalue, I need to use getFirstChild(n);
    But, I still didn't figure out the second
    problem. Actually, It works when I modified my xml file as following:
    <?xml version="1.0"?>
    <profile>
    <id>1</id>
    <name>Company</name>
    <des>master profile</desc>
    <subprofile><subid>1</subid><subname>group1</subname><subdesc>groupprofile</subdesc></subprofile>
    </profile>
    All the <subprofile>....</subprofile> must be in one line without any return. This is unbelievable! It suppose that xml does not matter new lines. I tested my code, it seems space is fine, but new line. Something must be wrong in my code.
    please give any suggestion. Thanks,
    Yudong
    null

  • Reading Data from a SQL table to a Logical file on R/3 appl. Server

    Hi All,
    We would like to create Master Data using LSMW (direct Input) with source files from R/3 Application Server.
    I have created files in the'/ tmp/' directory however I do not know how to read data from the SQL table and insert it into the logical file on the R/3 application server.
    I am new to ABAP , please let me know the steps to be done to acheive this .
    Regards
    - Ajay

    Hi,
    You can find lot of information about Datasets in SCN just SEARCH once.
    You can check the code snippet for understanding
    DATA:
    BEGIN OF fs,
      carrid TYPE s_carr_id,
      connid TYPE s_conn_id,
    END OF fs.
    DATA:
      itab    LIKE
              TABLE OF fs,
      w_file  TYPE char255 VALUE 'FILE',
      w_file2 TYPE char255 VALUE 'FILE2'.
    SELECT carrid connid FROM spfli INTO TABLE itab.
    OPEN DATASET w_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
                                                            " Server to write data
    LOOP AT itab INTO fs.
      TRANSFER fs TO w_file. "" Writing the data into the Application server file
    ENDLOOP.
    CLOSE DATASET w_file.
    OPEN DATASET w_file FOR INPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
                                                          " server to read data
    FREE itab.
    DO.
      READ DATASET w_file INTO fs.
      IF sy-subrc EQ 0.
        APPEND fs TO itab.
        OPEN DATASET w_file2 FOR APPENDING IN TEXT MODE ENCODING DEFAULT. "Appending more data to the file in the
                                                           " application server
        TRANSFER fs TO w_file2.
        CLOSE DATASET w_file2.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    Regards
    Sarves

  • Creation of External table by using XML files.

    I am in the process of loading of XML file data into the database table. I want to use the External Table feature for this loading. Though we have the external table feature with Plain/text file, is there any process of XML file data loading into the Database table by using External table?
    I am using Oracle 9i.
    Appreciate your responses.
    Regards
    Edited by: user652422 on Dec 16, 2008 11:00 PM

    Hi,
    The XML file which U posted is working fine and that proved that external table can be created by using xml files.
    Now My problem is that I have xml files which is not as the book.xml, my xml file is having some diff format. below is the extracts of the file ...
    <?xml version="1.0" encoding="UTF-8" ?>
    - <PM-History deviceIP="172.20.7.50">
    <Error Reason="" />
    - <Interface IntfName="otu2-1-10B-3">
    - <TS Type="15-MIN">
    <Error Reason="" />
    - <PM-counters TimeStamp="02/13/2008:12:15">
    <Item Name="BBE-S" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="BBE-SFE" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="ES-S" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="ES-SFE" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="SES-S" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="SES-SFE" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="CSES-S" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="CSES-SFE" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="UAS-S" Direction="Received" Validity="ADJ" Value="135" />
    <Item Name="UAS-SFE" Direction="Received" Validity="ADJ" Value="0" />
    <Item Name="SEF-S" Direction="Received" Validity="ADJ" Value="135" />
    </PM-counters>
    <PM-counters TimeStamp="03/26/2008:12:30">
    <Item Name="BBE" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="BBE-FE" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="ES" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="ES-FE" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="SES" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="SES-FE" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="CSES" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="CSES-FE" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="UAS" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="UAS-FE" Direction="Received" Validity="OFF" Value="0" />
    <Item Name="PSC" Direction="Received" Validity="OFF" Value="0" />
    </PM-counters>
    </TS>
    </Interface>
    </PM-History>
    My problem is the Item Name and Direction the value of both(ex PSCReceived or UASReceived) will be treated as the coulmn name of the table and '0' would be the value of that column. I am confused how to create the external table creation program for that.
    I would really appreciate your responses.
    Regards

  • Can we run SQL query on a XML file?

    Hi All
    I have an XML document which stores data of a table.
    My requirement is to retreive data from this XML document by firing SQL
    query.
    i.e "SELECT * FROM EMP" should give me the data from the EMP.XML file
    whose name is the table name.
    Does Oracle provide this feature to retreive data from an XML document
    by issuing the same SQL statement that is used in Database?
    Any pointer for this requirement is highly appreciated.
    Thanks in advance..
    Ashish

    select '<EMPLOYEE><EPNUM>' || EPNUM || '</EPNUM><EMPNAME>' || EMPNAME || '</EMPNAME></EMPLOYEE>' from EMPLOYEE;

  • Scenario: SAP  Tables Data to XML File

    Hi ,
    I need to create a Xml file at inbound  by taking input as SAP Tables Data at outbound. What are adapters to be used at outbound and inbound interfaces. Please correct me if iam wrong. At outbound side iam taking jdbc adapter and at inbound side iam taking file adapter. Can anybody guide me how to do this scenario with screen shots. Is it possible to use proxies for this scenario.
    Thanks in advance.
    Regards,
    Prem.S

    <i>What are adapters to be used at outbound and inbound interfaces.</i>
    JDBC and File
    <i>At outbound side iam taking jdbc adapter and at inbound side iam taking file adapter. </i>
    Will do
    <i>Can anybody guide me how to do this scenario with screen shots</i>
    /people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30
    /people/saravanakumar.kuppusamy2/blog/2005/01/19/rdbms-system-integration-using-xi-30-jdbc-senderreceiver-adapter
    /people/alessandro.berta/blog/2005/10/04/save-time-with-generalized-jdbc-datatypes
    <i>Is it possible to use proxies for this scenario.</i>
    Yes, but it would be easier to use JDBC
    Regards,
    Prateek

Maybe you are looking for