Forum Stats

  • 3,826,277 Users
  • 2,260,618 Discussions
  • 7,896,861 Comments

Discussions

Generating XML from dual

sreese
sreese Member Posts: 382
edited Jan 6, 2009 7:12AM in XML DB
Hey Gurus,

I'm trying to generate the following XML from dual, however, I keep getting an error message stating my top level is not defined. Any ideas? Thanks!

<PUDOOUTPUT>
<PKG>
<SHIPMENTID>12345</SHIPMENTID>
<ERROR>'NO DATA'</ERROR>
<ERRORTEXT>'Error: Cannot find shipper alias in SPL_SHIPPER_ACCOUNTS.'</ERRORTEXT>
</PKG>
</PUDOOUTPUT>



select xmlelement("PUDOOUTPUT",xmlelement("PKG",xmlelement("SHIPMENTID",i.shipmentid),
xmlelement("ERROR",'NO DATA'),
xmlelement("ERRORTEXT",'Error: Cannot find shipper alias in SPL_SHIPPER_ACCOUNTS.')))
into p_wms_output
from dual;

Best Answer

  • Jason_(A_Non)
    Jason_(A_Non) Member Posts: 2,097 Silver Trophy
    Answer ✓
    This works on 10.2.0.3
    select xmlelement("PUDOOUTPUT",xmlelement("PKG",xmlelement("SHIPMENTID",123456),
    xmlelement("ERROR",'NO DATA'),
    xmlelement("ERRORTEXT",'Error: Cannot find shipper alias in SPL_SHIPPER_ACCOUNTS.')))
    from dual;
    I suspect the issue is because you have "i.shipmentid" in your SQL statement as you have to table with an alias of "i" in your SQL statement. Do you mean something like l_shipmentid, as a variable from your PL/SQL code?

Answers

  • Jason_(A_Non)
    Jason_(A_Non) Member Posts: 2,097 Silver Trophy
    Answer ✓
    This works on 10.2.0.3
    select xmlelement("PUDOOUTPUT",xmlelement("PKG",xmlelement("SHIPMENTID",123456),
    xmlelement("ERROR",'NO DATA'),
    xmlelement("ERRORTEXT",'Error: Cannot find shipper alias in SPL_SHIPPER_ACCOUNTS.')))
    from dual;
    I suspect the issue is because you have "i.shipmentid" in your SQL statement as you have to table with an alias of "i" in your SQL statement. Do you mean something like l_shipmentid, as a variable from your PL/SQL code?
  • 678345
    678345 Member Posts: 3
    Hi,I need to generate XML FIle.Since i m new to XML.
    I had toregister the valid schema in my DB now i want to generate the XML file and with the refernce to this schema that xml file should be validated one against that schema.

    things i hav done till now
    ->i hav registered the scehma

    and the sample XML file provided by client
    <?xml version="1.0"?>
    <MEDMLDATA xmlns="PhaseForward-MedML-Inform4">
    <!-- Insert Trial/Study Information -->
    <STUDYVERSION UUID="id"
    STUDYNAME="name"
    VERSIONDESCRIPTION="text" />

    <!-- Insert Site Personnel Information -->
    <USER USERNAME="mmeyer"
    USERTYPE = "SITE"
    ACTIVESTATE = "TRUE"
    DELETESTATE = "FALSE"
    FIRSTNAME = "Marianne"
    LASTNAME = "Meyer"
    DISPLAYNAME = "Marianne Meyer"
    TITLE = ""
    HOMESCREENURL = "./Custom/HomeDefault.html"
    PHONE = "(555) 555-1212"
    FAX = "(555) 555-1212"
    ALTPHONE = ""
    EMAIL = "[email protected]"
    ADDRESS = ""
    ADDRESS2 = ""
    CITY = ""
    STATE = ""
    ZIPCODE = ""
    COUNTRY = ""
    BEEPER = ""
    USERMUSTRESETPASSWORD = "FALSE"
    DESCRIPTION = ""
    PASSWORD="changeme"/>

    <USER USERNAME="john"
    USERTYPE = "SITE"
    ACTIVESTATE = "TRUE"
    DELETESTATE = "FALSE"
    FIRSTNAME = "John"
    LASTNAME = "Meyer"
    DISPLAYNAME = "John Meyer"
    TITLE = ""
    HOMESCREENURL = "./Custom/HomeDefault.html"
    PHONE = "(555) 555-1212"
    FAX = "(555) 555-1212"
    ALTPHONE = ""
    EMAIL = "[email protected]"
    ADDRESS = ""
    ADDRESS2 = ""
    CITY = ""
    STATE = ""
    ZIPCODE = ""
    COUNTRY = ""
    BEEPER = ""
    USERMUSTRESETPASSWORD = "FALSE"
    DESCRIPTION = ""
    PASSWORD="changeme"/>

    <!-- Insert Site Information -->

    <SITE NAME= "(01) Massachusetts General Hospital" MNEMONIC="01"
    ADDRESS = "1 Main Street"
    ADDRESS2 = ""
    CITY = "Boston"
    STATE = "MA"
    ZIPCODE = ""
    COUNTRY = "USA"
    PHONE = "(555) 555-1212"
    ALTPHONE = ""
    FAX = ""
    EMAIL = ""
    TIMEZONE="(GMT-05:00) Eastern Time (US & Canada)"
    SITEDATEFORMAT = "MONTH_DAY_YEAR"
    STARTDATE = "April 1, 2005">
    </SITE>

    <SITE NAME= "(02) Boston General Hospital" MNEMONIC="01"
    ADDRESS = "1 Main Street"
    ADDRESS2 = ""
    CITY = "Boston"
    STATE = "MA"
    ZIPCODE = ""
    COUNTRY = "USA"
    PHONE = "(555) 555-1212"
    ALTPHONE = ""
    FAX = ""
    EMAIL = ""
    TIMEZONE="(GMT-05:00) Eastern Time (US & Canada)"
    SITEDATEFORMAT = "MONTH_DAY_YEAR"
    STARTDATE = "April 1, 2005">
    </SITE>

    <!-- Insert SITE and User Mapping Information -->

    <SITEGROUP SITENAME="(01) Massachusetts General Hospital">
    <USERREF USERNAME="mmeyer"/>
    </SITEGROUP>
    <SITEGROUP SITENAME="(02) Boston General Hospital">
    <USERREF USERNAME="John"/>
    </SITEGROUP>

    <!-- Insert User ROle Information -->
    <RIGHTSGROUP GROUPNAME="CRA">
    <!-- Insert Rights -->
    <RIGHTREF RIGHT="Print"/>
    <RIGHTREF RIGHT="Monitor"/>
    <RIGHTREF RIGHT="Canned Reports"/>
    <RIGHTREF RIGHT="View CRF"/>
    <RIGHTREF RIGHT="View Signature History for CRF"/>
    <RIGHTREF RIGHT="View Signature History for CRB"/>
    <RIGHTREF RIGHT="Data Export Listings"/>
    <RIGHTREF RIGHT="Freeze a CRF"/>
    <RIGHTREF RIGHT="Unfreeze a CRF"/>
    <RIGHTREF RIGHT="Mark and Unmark a CRF as SVed"/>
    <RIGHTREF RIGHT="Freeze a CRB"/>
    <RIGHTREF RIGHT="Unfreeze a CRB"/>
    <RIGHTREF RIGHT="Change Query State from Candidate to Open"/>
    <RIGHTREF RIGHT="Change Query State from Candidate to Deleted"/>
    <RIGHTREF RIGHT="Change Query State from Answered to Closed"/>
    <RIGHTREF RIGHT="Change Query State from Open to Closed"/>
    <RIGHTREF RIGHT="Change Query State from Reissued Candidate to Closed"/>
    <RIGHTREF RIGHT="Enter Query in Candidate State"/>
    <RIGHTREF RIGHT="Enter Query in Open State"/>
    <RIGHTREF RIGHT="Re-issue Query in Candidate State"/>
    <RIGHTREF RIGHT="Re-issue Query in Open State"/>
    <RIGHTREF RIGHT="Navigate by Visit"/>
    <RIGHTREF RIGHT="Navigate by Form"/>
    <RIGHTREF RIGHT="Reordering of Patients"/>

    <!-- Insert Users for role -->
    <USERREF USERNAME="mmeyer"/>
    <USERREF USERNAME="john"/>
    </RIGHTSGROUP>

    </MEDMLDATA>

    now i need to generate XML based on the above SAMple XML file,can anybody tell me how to generate XML file based on this..and after generating it should be validated against the registerd schema.
This discussion has been closed.