convert date oracle xml datetime

can someone show it please how to convert sysdate xml datetime as the 2010-01-27 T 09: 32:09.633

Thanks in advance,
Pradeep

I think passage clause expects an xmltype but here's sysdate, DATE.

You're right: my test case was on 11.2.0.1.

10.2.0.4 t would be

SQL> select * from v$version where rownum = 1
/
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
1 row selected.

SQL> select * from xmltable('xs:dateTime(.)' passing xmlelement(e, sysdate))
/
COLUMN_VALUE
-------------------------------------
 2010-02-27T00:00:00.000000+00:00
1 row selected.

Tags: Database

Similar Questions

  • How to convert a xs: date for XS: DateTime

    In my application, there are the following 2 cases, I need to manage:

    1. I have a "XS: date" and I need to convert it in "XS: DateTime".
    2. I have a "XS: date" and a "XS: Time" and I need to combine in ' XS: DateTime.

    Following the answer to this question on Stackoverflow, I tried both " xs:dateTime($date) "and" fn:dateTime($date, $time) " but none of them worked.

    When I used " xs:dateTime($date) " to manage the 1st case, I got the following exception during the OSB has reached the stage of conversion for the date:

    OSB Replace action failed updating variable "body": Error parsing XML: {err}XP0021: "2014-12-09": can not cast to {http://www.w3.org/2001/XMLSchema}dateTime: error: date: Invalid date value: wrong type: 2014-12-09

    When I used " fn:dateTime($date, $time) ", the transformation is not yet accepted by the IDE. " It displays the following error:

    line 113, column 42: "{http://www.w3.org/2004/07/xpath-functions}dateTime" unknown function (or number of arguments (2) is wrong

    For now, as a solution, I use 'concat' to combine the date and time fields in the 2nd case and add 'T00:00:00' to handle case 1, but I think that this is not a good approach.

    I would be very grateful if you could show me how I can correctly convert date in dateTime format fields.

    For the moment, I use OSB 11 g with the last v11.1.1.7.4 grouped patch applied.

    Found in the documentation that, in fact, only the working paper 2004-07 is implemented in this version:

    https://docs.Oracle.com/CD/E28280_01/admin.1111/e15867/XQuery.htm#OSBAG444

    According to the specifications, the casting of XS: date for XS: DateTime should work:

    XQuery 1.0 and XPath 2.0 functions and operators

    But as I mentioned previously, it is perhaps that you do not pass the correct data type.

    If the data are not based on a schema, then sch:jdOriginalPromisedDeliveryDate will be considered from type xdt: untypedAtomic and cannot be cast in all except XS: String.

    Is - it works better:

    {xs: date ($jdOriginalPromisedDeliveryDate) cast as xs: DateTime}

    ?

  • convert data from oracle to sql server functions

    In oracle, I get the result.

    floor ((trunc (INF. INFUSION_DTE) - trunc(S.BIRTH_DTE))/365.25) as PATIENT_AGE,)

    example: patient_age is 30

    How to write in sql server, looking for the same result as an oracle.

    CONVERT (VARCHAR (12), t.event_dte, 111) event_dte,.

    CONVERT (VARCHAR (12), p.birthday, 111) anniversary.

    Google is your friend... search for "sql server convert date of birth age" and you will get many examples. And here's one:

    DATEDIFF (hour, p.birthday, t.event_dte) / 8766 as age

    HTH,
    Brian

  • Insert data as XML into the Oracle Table

    Hi all

    I have a requirement where the data in XML format, and I need to insert into the Oracle Table. For example, I get XML data in the following format,
    < results >
    < row >
    < BANK_ACCOUNT_ID > 10010 < / BANK_ACCOUNT_ID >
    < BANK_ID > 300968 < / BANK_ID >
    Vision operations < LEGAL_ENTITY > < / LEGAL_ENTITY >
    < BANK_NAME > BofA < / BANK_NAME >
    < BANK_ACCOUNT_NUM > 10271-17621-619 < / BANK_ACCOUNT_NUM >
    < BANK_ACCOUNT_NAME > BofA-204 < / BANK_ACCOUNT_NAME >
    < BRANCH_NAME > New York < / BRANCH_NAME >
    USD < CURRENCY_CODE > < / CURRENCY_CODE >
    < BALANCE_DATE > 2007 - 11 - 09 < / BALANCE_DATE >
    < LEDGER_BALANCE > 432705900.56 < / LEDGER_BALANCE >
    < / row >
    < row >
    < BANK_ACCOUNT_ID > 10091 < / BANK_ACCOUNT_ID >
    < BANK_ID > 300984 < / BANK_ID >
    Vision industries < LEGAL_ENTITY > < / LEGAL_ENTITY >
    Barclay Bank < BANK_NAME > < / BANK_NAME >
    < BANK_ACCOUNT_NUM > 70986798 < / BANK_ACCOUNT_NUM >
    Bank Multi currency-626 < BANK_ACCOUNT_NAME > Barclays < / BANK_ACCOUNT_NAME >
    Reading < BRANCH_NAME > < / BRANCH_NAME >
    GBP < CURRENCY_CODE > < / CURRENCY_CODE >
    < BALANCE_DATE > 2007 - 11 - 14 < / BALANCE_DATE >
    < LEDGER_BALANCE > 24244085.24 < / LEDGER_BALANCE >
    < / row >
    < row >
    < BANK_ACCOUNT_ID > 10127 < / BANK_ACCOUNT_ID >
    < BANK_ID > 300968 < / BANK_ID >
    < LEGAL_ENTITY > SSC U.S. 01 < / LEGAL_ENTITY >
    < BANK_NAME > BofA < / BANK_NAME >
    < BANK_ACCOUNT_NUM > 4898744 < / BANK_ACCOUNT_NUM >
    < BANK_ACCOUNT_NAME > BofA SSC U.S. 02-7188 < / BANK_ACCOUNT_NAME >
    < BRANCH_NAME > New York < / BRANCH_NAME >
    USD < CURRENCY_CODE > < / CURRENCY_CODE >
    < BALANCE_DATE > 2007 - 11 - 28 < / BALANCE_DATE >
    < LEDGER_BALANCE > 10783815.28 < / LEDGER_BALANCE >
    < / row >
    < / results >

    I like to write PLSQL code that will receive these data with XML tags and insert it into the Oracle Table. Is this possible with built-in XML features provided in the Oracle database?

    Please Guide...

    Kind regards
    Priyanka

    But the problem is the file XML is to have the details of the records if you carefully observed the XML file. But by using more high statement select I get output in the following format.
    ORG_ID REQ_LINE PO_NUMBER EXPECTED_REC_QTY USER_NAME REQ_NUMBER
    204204 1444714450 11 64446445 11 OPERATIONSOPERATIONS

    The table has only one row, so you get a single row as output.
    I'm surprised that you find useful examples showing how to divide the data into several lines.

    (1) create the table with the following option, it will optimize the performance of storage and query for large XML documents:

    CREATE TABLE xxios_xml_data_test(xml_data XMLTYPE)
    XMLTYPE COLUMN xml_data STORE AS SECUREFILE BINARY XML
    ;
    

    (2) interview table with:

    SQL> select x.*
      2  from xxios_xml_data_test t
      3     , xmltable(
      4         '/Results/Row'
      5         passing t.xml_data
      6         columns ORG_ID           number       path 'ORG_ID'
      7               , REQ_NUMBER       number       path 'REQ_NUMBER'
      8               , REQ_LINE         number       path 'REQ_LINE'
      9               , PO_NUMBER        number       path 'PO_NUMBER'
     10               , EXPECTED_REC_QTY number       path 'EXPECTED_REC_QTY'
     11               , USER_NAME        varchar2(30) path 'USER_NAME'
     12       ) x
     13  ;
    
        ORG_ID REQ_NUMBER   REQ_LINE  PO_NUMBER EXPECTED_REC_QTY USER_NAME
    ---------- ---------- ---------- ---------- ---------------- ------------------------------
           204      14447          1       6444                1 OPERATIONS
           204      14450          1       6445                1 OPERATIONS
     
    
  • Any ideas to convert oracle XML or CLOB type collections

    Hi all

    Have actively tried to convert collections of oracle XML or CLOB objects to be stored in the table of database for logging purposes. Tried to look for clues. You can help.

    Here is the script that I created temporarily to try the code:

    DROP TABLE insert_table;

    CREATE TABLE insert_table
    (
    Serial NUMBER (9),
    first name VARCHAR2 (35),
    name VARCHAR2 (35),
    E-mail VARCHAR2 (65).
    home_phone NUMBER (10),
    work_phone NUMBER (10),
    CONSTRAINT serial_pk PRIMARY KEY (serial)
    );

    DELETE FROM temporary_table;

    INSERT INTO temporary_table VALUES (1, "Arthur", "Wright", "[email protected]", 5439021232, NULL);
    INSERT INTO temporary_table VALUES (2, 'will', "Ball", "[email protected]", 4379021000, NULL);
    INSERT INTO temporary_table VALUES (3, 'Kerwin","Mike","[email protected]", 9018236733, 6621232356);
    INSERT INTO temporary_table VALUES (4, 'Krammer', 'Cone', '[email protected]', NULL, 3238483323);

    DROP TYPE obj_detail FORCE
    /
    DROP TYPE obj_detail_list FORCE
    /

    CREATE or REPLACE TYPE obj_detail AS OBJECT
    (Serial NUMBER (9),
    full_name VARCHAR2 (70).
    Department VARCHAR2 (10),
    assessment VARCHAR2 (1))
    /

    CREATE or REPLACE TYPE obj_detail_list AS TABLE OF THE obj_detail
    /

    DECLARE
    CTX DBMS_XMLGEN.ctxHandle;
    XML CLOB.
    obj_det_list obj_detail_list: = obj_detail_list ();
    BEGIN
    SELECT obj_detail (series,
    last_name. first name,
    "Software."
    « A »)
    LOOSE COLLECTION obj_det_list
    Of insert_table;

    CTX: = DBMS_XMLGEN.newContext ("SELECT * FROM TABLE (obj_det_list)'");
    Dbms_output.put_line (ctx);

    XML: = DBMS_XMLGEN.getXML (ctx);
    Dbms_output.put_line (xml);

    DBMS_XMLGEN.closeContext (ctx);
    END;
    /

    Hello

    "" "You're almost there. '"

    The error you have is because you try to refer to a local variable (the collection) in a static SQL string.
    A solution would be to use a binding in the query variable, but only VARCHAR2 with DBMS_XMLGEN are allowed.

    However, you can bind the collection using a REF CURSOR:

    SQL> DECLARE
      2    ctx          DBMS_XMLGEN.ctxHandle;
      3    xml          CLOB;
      4    obj_det_list obj_detail_list := obj_detail_list();
      5
      6    rc           sys_refcursor;
      7
      8  BEGIN
      9
     10   SELECT obj_detail(serial,
     11                     last_name || first_name,
     12                     'Software',
     13                     'A')
     14   BULK COLLECT INTO obj_det_list
     15   FROM temp_table;
     16
     17   OPEN rc FOR SELECT * FROM TABLE(obj_det_list);
     18
     19   ctx := DBMS_XMLGEN.newContext(rc);
     20   xml := DBMS_XMLGEN.getXML (ctx);
     21   DBMS_OUTPUT.put_line (xml);
     22
     23   DBMS_XMLGEN.closeContext(ctx);
     24   CLOSE rc;
     25
     26  END;
     27  /
    
    
    
     
      1
      WrightArthur
      Software
      A
     
     
      2
      BallWill
      Software
      A
     
     
      3
      MikeKerwin
      Software
      A
     
     
      4
      ConeKrammer
      Software
      A
     
    
    
    PL/SQL procedure successfully completed
     
    

    You don't even need DBMS_XMLGEN:

    DECLARE
    
      xml          CLOB;
      obj_det_list obj_detail_list;
    
    BEGIN
    
     SELECT obj_detail(serial,
                       last_name || first_name,
                       'Software',
                       'A')
     BULK COLLECT INTO obj_det_list
     FROM temp_table;
    
     SELECT xmltype(cursor(select * from table(obj_det_list))).getClobVal()
     INTO xml
     FROM dual;
    
     DBMS_OUTPUT.put_line (xml);
    
    END;
    /
    
  • How to retrieve the image BLOB from database and display the image in rtf file using the Oracle XML Desktop 5.6.2 publication server?

    Hi all

    Here I have the image BLOB in the database files,

    I want to show the image to PDF using file to rtf using Oracle Xml Desktop Publisher,

    Hi all

    I found the solution for reading Image BLOB of data base & display in Pdf format.

    (1) read the image from DB.2) and then copy the picture using IO. UtilsCopy method to copy the picture

    (3) then encode with base64 converter then you will get the tag XML with Base64 as string then placed in your XML Code & preview the output, you will find the image

    Photo = (BlobDomain) currentRow.getAttribute ("Image");

    ByteArrayOutputStream OutputStream = new ByteArrayOutputStream();

                        Byte [] imageByte;
                          Byte [] b = null;
                        try {}
                        
                            IOUtils.copy (photo.getInputStream (), outputStream);
                            BS = outputStream.toByteArray ();
                            outputStream.flush ();
                            System.out.println("==="+BS.) Length);
                            Encoded byte [] is Base64.encodeBase64 (bs).;
                            encodedString = new String (encoded);
  • Convert to Oracle SQL to MS SQL

    Hello

    I use the following in Microsoft SQL Server for recordcount:

    declare @today datetime
    Select @today = convert (datetime, convert (varchar, GETDATE(), 112), 112)

    SELECT COUNT (*) FROM TABLE1 WHERE COALESCE (MODIFIEDDATE, CREATEDDATE) < @today-120


    How can I convert this Oracle script?

    MRP wrote:
    Hello

    I use the following in Microsoft SQL Server for recordcount:

    declare @today datetime
    Select @today = convert (datetime, convert (varchar, GETDATE(), 112), 112)

    SELECT COUNT (*) FROM TABLE1 WHERE COALESCE (MODIFIEDDATE, CREATEDDATE)<>

    How can I convert this Oracle script?

    Try this:

    select count(*) from table1
    where nvl(modifieddate,createddate) < trunc(sysdate)-120
    

    Edit: I did not bother to look what date format SQL server 112 - if it's something else that remove the component "hour" of the date, then you need to let us know.

    Published by: WhiteHat on October 18, 2010 15:17

  • TestStand database error - error converting data from nchar int type.

    Hello

    I used SQL standards database stored procedure options to store records of my test and I added the generated tables and stored procedures in a database and it seems to work OK in this form. However when I change the UUT_Results table to include a new column that contains the value of the primary key of another table in the database that I meet problems.

    I run a query that returns the primary key value (integer) for a given series number and stores the result as a global station (number format). The correct value is stored in the variable, but when I try to use this value in the stored procedure I get an error like below:

    An error occurred calling "LogResults" in "ITSDBLog" of "ZNIUGOL TestStand database logging"
    An error has occurred by executing a statement.
    Schema: SQL Server Stored Proc (NOR)
    Statement: UUT_RESULT.
    Description: Error converting data from nchar int type.
    Number:-2147217913
    NativeError: 8114
    SQLState: 22018
    Reported by: provider Microsoft OLE DB for SQL Server

    Source: TSDBLog

    My SQL statement for creating the table and the procedure for UUT_results are below:

    ~
    CREATE TABLE UUT_RESULT)
    Uniqueidentifier PRIMARY KEY ID,
    BoardDetailID int,
    STATION_ID varchar (255),
    BATCH_SERIAL_NUMBER varchar (255),
    TEST_SOCKET_INDEX int,
    UUT_SERIAL_NUMBER varchar (255),
    USER_LOGIN_NAME varchar (255),
    START_DATE_TIME is datetime,
    EXECUTION_TIME float,
    UUT_STATUS varchar (32),
    UUT_ERROR_CODE int,
    UUT_ERROR_MESSAGE varchar (255)
    CONSTRAINT UUT_RESULT_FK FOREIGN KEY (BoardDetailID) made REFERENCE BoardDetails)

    ~
    CREATE PROCEDURE InsertUUTRESULT
    @pID uniqueidentifier,
    @pBoardDetailID int,
    @pSTATION_ID varchar (255),
    @pBATCH_SERIAL_NUMBER varchar (255),
    @pTEST_SOCKET_INDEX int,
    @pUUT_SERIAL_NUMBER varchar (255),
    @pUSER_LOGIN_NAME varchar (255),
    DateTime @pSTART_DATE_TIME.
    float of @pEXECUTION_TIME.
    @pUUT_STATUS varchar (32),
    @pUUT_ERROR_CODE int,
    @pUUT_ERROR_MESSAGE varchar (255)
    AS
    INSERT INTO UUT_RESULT (ID, BoardDetailID, STATION_ID, BATCH_SERIAL_NUMBER, TEST_SOCKET_INDEX, UUT_SERIAL_NUMBER, USER_LOGIN_NAME, START_DATE_TIME, EXECUTION_TIME, UUT_STATUS, UUT_ERROR_CODE, UUT_ERROR_MESSAGE)
    VALUES)
    @pID,
    @pBoardDetailID,
    @pSTATION_ID,.
    @pBATCH_SERIAL_NUMBER,.
    @pTEST_SOCKET_INDEX,.
    @pUUT_SERIAL_NUMBER,.
    @pUSER_LOGIN_NAME,.
    @pSTART_DATE_TIME,.
    @pEXECUTION_TIME,.
    @pUUT_STATUS,.
    @pUUT_ERROR_CODE,.
    @pUUT_ERROR_MESSAGE)

    Any help would be appreciated,

    Thank you

    Stuart

    Stuart-

    What is the expression you are evaluating and the data type of the parameter that you defined in the Options database dialog box for the schema that you connect to data with?

  • convert date format period

    Hi all

    Here are my existing query which I run another tool to extract data from oracle-

    Select * from transactionTbl

    WHERE

    DATE > = TO_DATE (' $(vAppStartDate)', "DD/MM/YYYY")

    AND DATE < = TO_DATE (' $(vAppEndDate)', "DD/MM/YYYY")

    variables-

    -vAppStartDate = 06/01/2014

    -vAppEndDate = 30/06/2015

    Rather than use the Date column in the WHERE condition, I want to use PeriodID of column existing in the same table, to make the query faster.

    The period column is in below format.

    PeriodID format-> 201294 //means 2012Q 4. So 9 means Q

    Since I'm on variables, the values are always to the date format, so my requirement is first change variable date from periods of format.

    I wrote the pseudo-code, because I of course know how to convert date format periodID. Q also means in the periodID 9.

    Select * from transactionTbl

    WHERE

    PeriodID > = period_function (TO_DATE (July 1, 14 ',' DD/MM/YYYY '), 'YYYYxx')

    AND PeriodID > = period_function (TO_DATE (July 1, 15 ',' DD/MM/YYYY '), 'YYYYxx')

    Please help me with the query.

    Thank you!

    Calling a user-defined function is likely to slow down your query.

    What's the problem with just using regular date formatting strings for example

    SQL > select to_char (to_date('15/09/2014','DD/MM/YYYY'), 'YYYY "9" Q') of double;
    TO_CHA
    ------
    201493

    1 selected line.

  • How to print barcodes in Oracle XML Publisher report

    Hello

    We have a report of rdf that prints the bar code in the start page based on a custom procedure of MarkView. It works well with Oracle Reports.

    But given that this report was a matrix report, we change it a linear relationship by Oracle XML Publisher report.

    We have every possible thing in the new Oracle XML report... But we are not able to print data from barcode which is BLOB in the XML report...

    Can someone help me on this? We have dates UAT at the corner...

    We have a RTF model.

    Help as soon as possible.

    Thank you

    AFA

    Hello

    I even referring to this blog.

    How to create a report with a field of image (.jpeg). Maniacs Oracle & #039; Notes

    The bar code is original

    Thank you and best regards,

    AFA

  • convert date in words

    I want to convert date in words
    example: 27-mar-2013 to 27 March twenty thirteen


    running version
    Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    AMT for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> SELECT REPLACE (TO_CHAR (TO_DATE ('25-Mar-2013', 'dd-mm-yyyy'),'fmddspth month year'),'-',' ') spdt FROM DUAL;
    
    SPDT
    -------------------------------------------------------------------
    twenty fifth march twenty thirteen
    
    SQL> SELECT REPLACE (TO_CHAR (sysdate,'FMDdspth Month Year'),'-',' ') spdt FROM DUAL;
    
    SPDT
    -------------------------------------------------------------------
    Thirtieth May Twenty Thirteen
    
  • to retrieve data from xml data type

    Hello...
    I have a doubt in the oracle database... Here's how to retrieve data from xml data type?

    Like this...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select xmltype('
      2  
    3 4 toMonth5 5 ctTestPan1 6 costType2 7 toYear2012 8 fromMonth12 9 fromYear2011 10 11
    ') as xml from dual) 12 -- 13 -- end of sample XMLDATA, use below query on your own table etc. as required 14 -- 15 select x.* 16 from t 17 ,xmltable('/DETAILS/FIELDS_VALUES/FIELD' 18 passing t.xml 19 columns name varchar2(30) path './NAME' 20 ,val varchar2(10) path './VALUE' 21* ) x SQL> / NAME VAL ------------------------------ ---------- toMonth 5 ctTestPan 1 costType 2 toYear 2012 fromMonth 12 fromYear 2011 6 rows selected.
  • #DATA # table XML

    The field #DATA # Chart XML takes data from your SQL query and it wraps in XML so that AnyChart can return the table correctly.

    Is it possible for me to customize how the XML is generated?
    Where can I find the definition of the field #DATA #?

    Thank you
    Austin

    Hi Austin,.

    First of all, what APEX version do you use? Before APEX 4.0, Flash cards are supported using AnyChart 3.3 graphics, but with APEX 4.0, we have integrated AnyChart 5 cards. The XML reference differs a lot between releases two chart, so I just want to make sure I provide you with the correct information for the version of graphics you ' using #re.

    The #DATA substitution string # on your list THAT XML is replaced at run time with XML tags containing the result set of your query for the chart series. If the XML table did not contain the #DATA substitution string #, then we assume that you provide your own data, and the chart series query will not be used. The generation of the XML tags for data differs from the type of graph type chart for example data for a pie chart labels are very different from that of a Gantt chart. Generally, users don't need to worry about this. They just need to provide the graphic series query, and the underlying logic supports the rest. However, if you need to customize only XML tags for data, for some reason, then you essentially have two options here:

    (1) hard-code XML necessary in the area of Custom XML in your chart. This would require that you set "Use Custom XML" Yes, on the page table and in the area of Custom XML attributes, replace #DATA # by your XML example

    
      
        
        
        
        
        
        
        
        
      
    
    

    NOTE: the above XML code is AnyChart 5 format, so if you use graphics AnyChart 3.3 XML code will look very different. I can provide a sample for that if needed. The reference XML 3.3 AnyChart are available here: http://3.anychart.com/products/docs/anychart/index.htm and the reference to XML AnyChart 5 are available here: http://anychart.com/products/anychart/docs/xmlReference/index.html.

    or

    (2) to generate your own data, through a process of page labels, for example, save the output in a page hidden item and then make reference to this element of the page on the list XML custom... again, you would remove the #DATA substitution string # and replaced by a reference to a hidden example item & P1_DATA. I had an example how to do that on my example of thresholds in sample, here: http://apex.oracle.com/pls/apex/f?p=36648:35. Basically, I used an application process to generate XML, to be customized because the tag must refer to a threshold attribute for example , and by default, the tag does not reference this attribute.

    I hope that the above information is useful and if you need further explanation or assistance, let me know.

    Kind regards
    Hilary

  • Using functions Oracle XML - sys_xmlgen and dbms_xmlgen

    I am new to Oracle 10 g and XML. I've been reading and practice with examples and understand a point of what is happening.

    Here's my problem: I have a student athlete who can have many rewards. How can I get several scholarships to work with sys_xmlgen or dbms_xmlgen? Or is this even possible?
    The data is stored in tables, XMLType.
    This problem uses several tables as a sport table, table of students and a table of prices.

    There is an example of output of a student with multiple tags within the tag of the student price:

    < student schoolSidNumber = '999-12-6745' fulltimeEnrollmentTermHere = 'S1' fulltimeEnrollmentYearHere = "2003" action = "none" firstName = "Import" lastName = 'Test' recruited 'M' = sex = 'Y' comments = date of birth "Created from the process of import." = '1971-09-12' Address1 = "123 University Drive" city = 'University City' State 'IN' = >
    < guardianName warden = "Mr. & amp; Ms. Import Test' homeFlag = 'Y' Address1 = "123 Avenue House" city = 'Brazil' state 'IN' = / >
    < year value "2008" action = 'none' = >
    < sport sportCode = "MBB" initialCounterFlag = 'Y' action = 'save' / >
    < aidLimits sportCode = "MBB" grantInAidAmt = "10000" costAttendAmt = "11000" / >
    < price action = 'save' saAidId = '0' fundCode = 'ATHLETES' sportCode = "MBB" rolloverFlag = "N" awardPeriod = "FY" awardAmount = "5000" awardDate = "2005-08-13" / >
    < price action = 'save' saAidId = '0' fundCode = "INST" sportCode = "MBB" rolloverFlag = "N" awardPeriod = "FY" awardAmount = "2000" awardDate = "2005-08-13" / >
    < continuingEligibility classDescription = "FRESHMAN" degreeDeclareDate = "" academicIneligible = "N" degreeReqHours = '120' degreeId = '1' saCumulativeGpa = "3,397" "
    totalDegreeHours = "26" / >
    < term action = 'save' termCode = 'S1' hoursAttempted = '12' hoursEarned = '12' gpa = "4.0" fullTimeFlag = "Y" / >
    < term action = 'save' termCode = 'S2' hoursAttempted = hoursEarned "14" = "14" gpa = '3.0' fullTimeFlag = 'Y' / >
    < / year >
    < original acceptedDate = "2002-04-01" >
    < testScore p1Score = '400' p2Score = '400' testCode = "S" testDate = "1999-05-31" / >
    < / original >
    < / student >

    I know I could do with dbms_output.put_line tags, but I want to take full advantage of Oracle XML.
    Any help would be greatly appreciated.

    Published by: user9507990 on August 5, 2009 08:37

    OK, I probably messed up a bit with joins (got duplicates), but here's the idea:

    SELECT
    xmlelement("students",
     xmlagg(
      xmlelement("student",
                 xmlattributes(stu.student_id as "studentId",
                               stu.student_last_name as "lastName",
                               stu.student_first_name as "firstName"),
       xmlagg(
        xmlelement("sport",
                   xmlattributes(spo.sport_actc_code as "sportCode",
                                 spo.sport_term_code as "termCode")
        )
       ),
       xmlagg(
        xmlelement("award",
                   xmlattributes(awd.award_fund_code as "fundCode",
                                 awd.award_accept_amt as "awardAmount",
                                 to_char(awd.award_accept_date, 'YYYY-MM-DD') as "awardDate")
        )
       )
      )
     )
    )
    FROM students stu
         JOIN sports spo ON spo.sport_pidm = stu.student_pidm
         JOIN terms ter ON ter.term_code = spo.sport_term_code
         JOIN awards awd ON awd.award_aidy_code = ter.term_aidy_code AND awd.award_pidm = stu.student_pidm
    GROUP BY stu.student_id, stu.student_last_name, stu.student_first_name
    ORDER BY stu.student_id;
    

    The query uses the XMLELEMENT and XMLAGG to build the structure:
    The root element is 'students', to which we add several child nodes of "student".
    XMLATTRIBUTES is used to set the attributes of an element.

    Another solution would be to produce a "gross" in canonical format (...) xml document Oracle from using DBMS_XMLGEN this query:

    SELECT stu.student_id, stu.student_last_name, stu.student_first_name,
           spo.sport_actc_code, spo.sport_term_code,
           awd.award_fund_code, awd.award_accept_amt, to_char(awd.award_accept_date, 'YYYY-MM-DD') award_accept_date
    FROM students stu
         JOIN sports spo ON spo.sport_pidm = stu.student_pidm
         JOIN terms ter ON ter.term_code = spo.sport_term_code
         JOIN awards awd ON awd.award_aidy_code = ter.term_aidy_code AND awd.award_pidm = stu.student_pidm
    ORDER BY stu.student_id, spo.sport_actc_code, awd.award_fund_code;
    

    And then apply an XSL transformation to achieve the desired result.

    Hope that helps.

    Published by: odie_63 on August 6, 2009 14:44

  • There will be review certification essentials (OCS) for the GREAT DATA Oracle?

    Hello

    I often hear about this subject called BIG DATA much in the arena of the database

    and even at Oracle.

    Will there be a Big data Oracle Certification?

    Roger

    For now, I have no information on this subject.

    Kind regards
    Brandye Barrington

    Oracle Certification program.

Maybe you are looking for