Create the flat file data from the oracle table

d_adp_num char (10)
d_schd_date tank (8)
d_sched_code tank (25)
d_pay_code char (50)
d_mil_start char (4)
d_mil_end char (4)
d_duration char (5)
d_site_code char (4)
d_dept_id tank (6)

Select payroll_id,
schedule_date,
reason_code, (sched_code)
reason_code, (pay_code)
start_time,
end_time,
total_hours,
site_code,
department_id
of dept_staff
where schedule_date between (sysdate + 1) and (sysdate + 90)


loading data for the date range instead.
sched_code - if 'Unavailable' reason_code = 'OD' and 'THE '.

pay_code - "Berevevement BD" If reason_code = "BD".
"UP PTO without reasonable excuse" If reason_code = 'UP '.
"RG" If reason_code = "SH".
"PTO" If reason_code = "GO".
Here are some...

start_time and end_time - convert military time
based on start_ampm and end_ampm

On this basis, I need help to create a flat file. Sewing of the flat and data file in dept_staff sample

If site_code is there so no need to get department_id (see the sample flat file)
------------------------------------

examples of data to flat file

ZZW002324006072012 PTO
0800160008.00
ZZW002428106072012 RG
1015174507.50HM34
ZZW002391606072012 RG
1100193008.50
ZZW002430406072012 RG
1100193008.50 130000
----------------------------

dept_staff table data

REASON_CODE_1 PAYROLL_ID SCHEDULE_DATE REASON_CODE START_TIME, END_TIME START_AMPM END_AMPM TOTAL_HOURS SITE_CODE DEPARTMENT_ID
ZZW0024468 08/06/2012 HS HS 730 HAS 400 850 12 P
ZZW0000199 08/06/2012 HS HS 730 HAS 400 850 14 P
ZZW0023551 08/06/2012 SH SH 1145 A 930 975 GH08 95 P
ZZW0024460 08/06/2012 SH SH 515 HAS 330 P 1025 GH08 95
ZZW0023787 08/06/2012 SH SH 630 HAS 300 850 24 P
ZZW0024595 08/06/2012 TR TR 730 HAS 400 850 90 P
ZZW0023516 08/06/2012 OD OD 800 HAS 400 800 95 P
ZZW0023784 08/06/2012 OD OD 800 HAS 400 800 5 P
ZZW0024445 08/06/2012 SH SH 1145 A GH08 930 975 5 P
ZZW0024525 08/06/2012 OD OD 800 HAS 400 800 23 P
ZZW0024592 08/06/2012 TR TR 730 HAS 400 850 5 P
ZZW0024509 08/06/2012 SH SH 95 MK21 830 HAS 330 P 700

ZZW0023916 06/14/2012 SH SH 1100 A 850 27 730 P

How to ask questions
SQL and PL/SQL FAQ

UTL_FILE allows to write the OS file

Tags: Database

Similar Questions

  • retrieve data from an oracle table

    Hello

    I downloaded a piece of data in xml format in oracle and successful upload but trying to retrieve the data it reterieve 0 records. Oracle version is given below:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    create table temp_loading_lob(
                                            xml_id varchar2(3),
                                            q_clob CLOB
                                             )
    nologging
    
    
    create table temp_loading_xml
    nologging as
    select xml_id,xmltype( q_clob) q_xml
    from temp_loading_lob;
      
    XMl Data
    
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <Root xmlns="http://www.w3.org/2000/10/XMLSchema">
         <Accounts ApplicationVersion="7.2.1.6 (10-02-2012)" Database="Q" DateExported="20120813">
              <Account AccountID="QF8AA000">
                   <AccountName>124 On Brunswick Bed &amp; Breakfast</AccountName>
                   <Addresses>
                        <Address AddressID="aQF8AA000YMY">
                             <Description>Physical</Description>
                             <Address1>124 Brunswick Drive</Address1>
                             <Address2>Brunswick Park - RD 4</Address2>
                             <Address3></Address3>
                             <Suburb></Suburb>
                             <City>Rotorua</City>
                             <Postcode></Postcode>
                        </Address>
                        <Address AddressID="aQF8AA000WXX">
                             <Description>Postal</Description>
                             <Address1>PO Box 7365</Address1>
                             <Address2></Address2>
                             <Address3></Address3>
                             <Suburb>Te Ngae</Suburb>
                             <City>Rotorua</City>
                             <Postcode>3042</Postcode>
                        </Address>
                   </Addresses>
    </Accounts>
    </Account>
    </Root>
    
    Query used to reterive data 
    
    select po.*
    from temp_loading_xml p,
         XMLTable('/Accounts/Account'
                   PASSING p.q_xml
                   COLUMNS
                      AccountID varchar2(20) PATH '@AccountID'
                      ,AccountName varchar2(20) PATH 'AccountName'                  
                                  )po
    I am trying to catch my mistake but impossible to repair. Any help will be ge greatly appretiated. How can I close my thread?

    Best regards
    Zaid

    Mark the thread as 'Response' (as you already have) and choose 'Useful' or 'Correct' (or no) for the positions in question.

  • Create a flat file reconciliation events - a matter of design

    Hello

    I am currently evaluating an existing implementation of IOM to rebuild using OIM 11 g and have questions about the ideal method to create events for the reconciliation of a flat file.

    The current implementation uses a web service call to process a flat file and creates reconciliation events. It runs every hour.

    Although this looks cool, but I thought there was no need to go as far.

    If IOM cannot consume the flat file directly, which means that if he needs massage data, I can always load the flat file data in an external table, write a pl/sql procedure to transform the data and put it into a global temporary table, and create events of reconciliation like that.

    What would be the ideal method to load data from a flat file in IOM?

    Thank you

    Khanh

    If it is a flat file, then watched GTC option? And why no staged between the two? IOM can read flat files very well either through GTC or write your own recon code.

    -Marie

  • 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
     
    
  • ODI - read CSV file and write to the Oracle table

    Hello world

    After 4 years, I started to work again with ODI, and I'm completely lost.

    I need help, I don't know what to use for each step, interfaces, variables, procedures...

    What I have to do is the following:

    (1) reading a CSV file-> I have the topologies and the model defined

    (2) assess whether there is a field of this CSV file in TABLE A-> who do not exist in the table is ignored (I tried with an interface joining the csv with the TABLE model a model and recording the result in a temporary data store)

    Evaluate 3) I need to update TABLE C and if not I need to INSERT if another field that CSV exists in TABLE B-> if there

    Could someone help me with what use?

    Thanks in advance

    Hi how are you?

    You must:

    Create an interface with the CSV template in the source and a RDBM table in the target (I'll assume you are using Oracle). Any type of filter or the transformation must be defined to be run in the stadium. (you must use a LKM for SQL file and add an IKM Sql control (it is best to trim them and insert the data when it cames to a file if you want after this process, you may have an incremental update to maintain history or something like that).)

    For validation, you will use a reference constraints in the model of the oracle table: (for this you need a CKM Oracle to check constraints)

    Then, you must select the table that you sponsor and in the column, you choose which column you will match.

    To article 3, you repeat the above process.

    And that's all. Pretty easy. If you do not have the two tables that you need to use your validation that you need to load before loading the CSV file you need valid.

    Hope this can help you

  • Download the XML data in an oracle table

    I need to download data from an XML file to the oracle table.
    I use 10.1.0.3.0 database.

    Refer to the Oracle XML DB Developer's Guide - loading XML in Oracle XML DB content

  • How to create the logical tables &amp; how to give joints according to obiee 11g?

    Hello

    I have again to obiee 11g. I want to create the logical tables in MDB layer.

    After that I want to give joins according to MDB.

    I don't know, how to create the logical tables and how to give joints according to obiee 11g?

    Please help me.

    Thanks in advance,

    A.Kavya

    Hello

    The new logical table is right click on the MDB itself, for the join you generally in the business model diagram (again right click on objects).

    Maybe it's better if you start from a kind of tutorial to at least have an overview of what is happening where (layer business and physical layer etc.).

    Take a look at what Oracle has available: Oracle BI EE 11 g

    And no doubt, it can be a good start: https://apexapps.oracle.com/pls/apex/f?p=44785:24:0:NO:P24_CONTENT_ID, P24_PREV_PAGE:9787, 2

  • flat file to flat file with no intermediate loading table...

    Is there that something called a flat file for loading of flat file? For example, I have a file flat source with a few 100 lines, but with a few unwanted spaces. Now, I want to remove the empty spaces and put in another flat file in the flat file target. NO intermediary TABLES of loading / unloading ADMITTED. How is that possible using OWB?

    I guess I can load flat file source, file flat target and logic of expression necessary to get what I want. But I got an error VLD-1111. What I interpret the error, it's that I can't use the file as a table to generate a script.

    How to remedy this situation.

    Hello

    Check the design of map here:
    http://blogs.Oracle.com/warehousebuilder/file_2_file.jpg

    Now in OWB 11 GR 2, you can have the file-to-file card designs flat to flat and use templates of code that allow the mapping to run on an agent (the Agent Control Center), where the file is put in scene can be as light a system you want, for example in the mapping I use MySQL , but might be Derby or Hypersonic SQL, this will allow you to do things in the file as join with other files, transformations etc.

    See you soon
    David

  • XML from the Oracle Table data

    Hi all

    I'm new to this network. I'm also new to oracle XML package. I want a help with the query below.

    CREATE TABLE EMP (ID NUMBER PRIMARY KEY, NAME VARCHAR2 (10), TELEPHONE NUMBER);

    INSERT INTO EMP (ID, NAME, PHONE) VALUES (11, 'Joy', 1234);
    INSERT INTO EMP (ID, NAME, PHONE) VALUES (22, 'Mike', 5678).
    INSERT INTO EMP (ID, NAME, PHONE) VALUES (33, "Jason", NULL);
    COMMIT;

    I want to export data from the EMP table in an XML file with the format below.

    Power required:

    <? XML version = "1.0" encoding = "UTF-8"? > < Joy STATICDATA > < EMP > < ID > 11 < /ID > < NAME > < / NAME > < / EMP > < / STATICDATA >
    <? XML version = "1.0" encoding = "UTF-8"? > < Mike STATICDATA > < EMP > < ID > 22 < /ID > < NAME > < / NAME > < / EMP > < / STATICDATA >
    <? XML version = "1.0" encoding = "UTF-8"? > < Jason STATICDATA > < EMP > < ID > 33 < /ID > < NAME > < / NAME > < / EMP > < / STATICDATA >

    I used some XML functions and you wrote the following query.

    Select XMLROOT (XMLELEMENT (staticdata, XMLELEMENT (EMP, XMLELEMENT(ID,ID), XMLELEMENT(NAME,NAME))), version "1.0" encoding = "UTF - 8') xml EMP;

    my query output:

    <? XML version = "1.0" encoding = "UTF-8"? >
    < STATICDATA >
    < EMP >
    < ID > 11 / < ID >
    Joy of < NAME > < / NAME >
    < / EMP >
    < / STATICDATA >
    <? XML version = "1.0" encoding = "UTF-8"? >
    < STATICDATA >
    < EMP >
    < ID > 22 / < ID >
    < NAME > Mike < / NAME >
    < / EMP >
    < / STATICDATA >
    <? XML version = "1.0" encoding = "UTF-8"? >
    < STATICDATA >
    < EMP >
    < ID > 33 / < ID >
    Jason < NAME > < / NAME >
    < / EMP >
    < / STATICDATA >


    But I want the out as the power required above. all records in a single line. can someone help me achieve the desired output. also can I export all columns of the table with something like select * from the table in the XML file?

    Thank you
    Delobelle

    Don't know why you need it on a single line, but you could:

    Select XMLTYPE (REGEXP_REPLACE (XMLROOT (XMLELEMENT (staticdata, XMLELEMENT (EMP, XMLELEMENT(ID,ID), XMLELEMENT(NAME,NAME))), version "1.0" encoding = "UTF - 8'), CHR (10) |)) ' *<><'))>
    FROM EMP;

    SY.

  • Best LKM to move the data from in Oracle of a diagram to another diagram

    Hi gurus,

    What is the best KM to move data from one schema to another within the same oracle database schema.

    Thanks in advance

    It seems that you have created two servers of data for the two schemas. You have created two physical schema inside the single database server.

    Use LKM oracle to Oracle dblink.

    "LKM sql for sql" is used to migrate data from DB DB (DB2 to oracle or DB2 to SQL Server, etc.) but is not recommended for large volumes.

    Published by: user8427112 on December 2, 2012 06:07

    Published by: user8427112 on December 3, 2012 08:08

  • Analyze the flat file data in a nested structure.

    This has been driving me crazy all day long.

    I have a flat data file I want to analyze in a nested data structure.

    Small sample data:

    0 HEAD
    1 SOUR FTW
    2 VERS Family Tree Maker (16.0.350)
    2 NAME Family Tree Maker for Windows
    2 CORP MyFamily.com, Inc.
    3 ADDR 360 W 4800 N
    4 CONT Provo, UT 84604
    3 PHON (801) 705-7000
    0 TRLR
    

    If anyone recognizes this, yes it's a small piece of a GEDCOM file.  That's what I'm trying to analyze.  For someone who is not familiar with this data format.  The first number is the level of a data element.  Level 0 are elements of the root of a data segment.  Level 1 lines relate to the data of level 0 line previous closest.  Level 2 lines relate to the level 1 data line that precedes the closest. And so on.

    Here is an example of the desired output, the different elements to the related parent of nesting.

    <cfset foobar = {
     HEAD = {lvl=0,
     SOUR = {lvl=1,data="FTW",
     VERS = {lvl=2,data="Family Tree Maker (16.0.350)"},
     NAME = {lvl=2,data="Family Tree Maker for Windows"},
     CORP = {lvl=2,data="MyFamily.com, Inc.",
     ADDR = {lvl=3,data="360 W 4800 N",
     CONT = {lvl=4,data="Provo, UT 84604"}},
     PHON = {lvl=3,data="(801) 705-7000"}}}},
     TRLR = {lvl=0}
    }>
    
    <cfdump var="#foobar#">
    

    I think I'm looking at a kind of recursive function to embed these data correctly, but I just can't figure out how to do.

    I have this basic function that will display each line of data in a separate structure key

    <cffunction name="parseFile">
         <cfargument name="file" required="yes">
         <cfargument name="line" required="no" type="string" default="">
         
         <cfscript>
              var returnStruct = structNew();
              var subStruct = structNew();
              var cur_line = "";
              var next_line = "";
              var line_lvl = "";
              var line_key = "";
              var loop = true;
              
              if (len(trim(arguments.line)) EQ 0) {
                   cur_line = fileReadLine(arguments.file);
              }
              else
              {
                   cur_line = arguments.line;
              }
              
              do {
                   if (not FileISEOF(arguments.file)) {
                        next_line = fileReadLine(arguments.file);
                   }
                   else
                   {
                        next_line = "-1";
                        loop = false;
                   }
                   
                   line_lvl = listFirst(cur_line, ' ');
                   cur_line = listRest(cur_line, ' ');
                   line_key = listFirst(cur_line, ' ');
                   cur_line = listRest(cur_line, ' ');
                   
                   returnStruct[line_key] = structNew();
                   returnStruct[line_key]["level"] = line_lvl;
    
                   cur_line = next_line;
              } while (loop);
              
              return returnStruct;
         </cfscript>
    </cffunction>
    
    <cfscript>
         gedcom_file = FileOpen(getDirectoryFromPath(getCurrentTemplatePath()) & "Ian Skinner.GED","read");
         /*gedcom_data = {individuals = structNew(),
                        families = structNew(),
                                             sources = structNew(), 
                                             notes = structNew()};*/
                                             
         gedcom_data = parseFile(gedcom_file);
    </cfscript>
    
    <cfdump var="#gedcom_data#" label="Final Output">
    

    I tried many ways to recursively call this function in order to nest the elements.  None of them have produced await in the above example of hand coded output.  Which made me the closest is recursive call, the function parseFile() towards the end of the while loop if the following line is greater than the current level of line:

    if (listFirst(next_line,' ') GT line_lvl) {
         parseFile(arguments.file,next_line);
    }
    


    It works pretty well, as long as the next level of line is the same as or higher than its previous level of the line.  But once the next line level is lower, the recursive call will not return to the appropriate parent level.  The current function call ends just on a loop on the data file.  Everything that I tried to provide a correct output for recursive function calls when the next data line belongs to a line parent just a horribly distorted data.

    Yes, that's exactly it. I think that the node must always be added to the stack.

    I just had a period gave me. But that's what I thought.

    That is to say...

    While (not FileISEOF (gedcom_file)) {}

    line = fileReadLine (gedcom_file);

    extract data from the node

    node = {};

    node.LVL = listFirst (line, "");

    line = listRest (line, "");

    key = listFirst (line, "");

    If (listLen (line, "") gt 1) {}

    node. Data = listRest (line, "");

    }

    Download the most recent ancestor of the battery

    lastNode = stack [1];

    If it is a brother/ancestor, look for its parent

    While (arrayLen (stack) & node.lvl lte lastNode.lvl) {}

    arrayDeleteAt (battery, 1);

    lastNode = stack [1];

    }

    Add to the stack

    arrayPrepend (stack, node);

    Add this node from its parent

    lastNode [key] = node;

    }

  • Issue, while reading the file data from a JMS queue

    Hello

    I'm trying a simple case to receive the XML of the JMS queue and inside BPEL use Assign activity to read data in a temporary variable to check the file from the JMS queue. I do the archive file name, CHRAPcXMLInvoices_DUNS_XXXXXXX_datestamp.dat, XXXXXX as the mapping of the identity of the XML from the JMS queue. Some reasons is not mapping... Can someone help me on this please? I stuck here because my final requirement was to insert the data from the XML file in a custom table, but because of this, it fails saying "can not insert a null" which means that some how he does not read the data...

    I enclose the screen... Please help...

    Hello

    I would try to replicate the same at my end, but you can do the following to me.

    You could manually put the message ("but add xmlns ="http://www.example.org" in cXML item payloadID") in the JMS and test it.

    For Ex:

    " xmlns ="http://www.example.org">"

    The XML message is clearly the namespace XSD lacks. The BPEL is looking in the correct namespace (xmlns:ns3 ="http://www.example.org" ") of the XML message, but as space of names are not added to the incoming message sound throw an exception.

    So, try to add the namespace to the XML message and publish manually in the JMS queue to start the process.

  • Generation of the XML from the Oracle tables

    I'm using Oracle 11 g R1.

    I have two tables header and the line:

    CREATE THE TABLE HEADER
    (
    EXPENSE_INFO VARCHAR2 (2000).
    NUMBER OF ERROR_CODE,
    REASON_OF_FAILURE VARCHAR2 (4000)
    )
    /


    CREATE THE ROW IN THE TABLE
    (
    EXPENSE_INFO VARCHAR2 (2000).
    DATE OF EXPENSE_DATE,
    EXPENSE_CODE VARCHAR2 (10),
    EXPENSE_REF VARCHAR2 (2000).
    GROSS_AMOUNT NUMBER,
    NUMBER OF TAX_AMOUNT,
    NUMBER OF ERROR_CODE,
    REASON_OF_FAILURE VARCHAR2 (4000)
    )
    /

    These tables are linked by the EXPENSE_INFO column.

    Complete the tables with the following data:

    Insert in the header (ErrorCode, EXPENSE_INFO, REASON_OF_FAILURE)
    values ('A', 0, 'SUCCESS');

    Insert (EXPENSE_INFO, EXPENSE_DATE, EXPENSE_CODE, EXPENSE_REF, GROSS_AMOUNT, TAX_AMOUNT, ERROR_CODE, REASON_OF_FAILURE) online
    values ('A', to_date (December 14, 2012 ', 'dd-mm-yyyy'), 'ABC', 'HOTEL', 100, 500, 0, 'SUCCESS');

    Insert (EXPENSE_INFO, EXPENSE_DATE, EXPENSE_CODE, EXPENSE_REF, GROSS_AMOUNT, TAX_AMOUNT, ERROR_CODE, REASON_OF_FAILURE) online
    values ('A', to_date (December 14, 2012 ', 'dd-mm-yyyy'), 'DEF', 'MOVIE', 10, 50, 1, "Cost Code does not exist.");

    Insert in the header (ErrorCode, EXPENSE_INFO, REASON_OF_FAILURE)
    values ('B', 1, "Emp Id does not exist.");

    Insert (EXPENSE_INFO, EXPENSE_DATE, EXPENSE_CODE, EXPENSE_REF, GROSS_AMOUNT, TAX_AMOUNT, ERROR_CODE, REASON_OF_FAILURE) online
    values ('B', to_date (December 14, 2012 ', 'dd-mm-yyyy'), "XYZ", "MILEAGE", 200, 300, 0, 'SUCCESS');



    I want to generate the XML following these tables:


    COSTS of <>
    < EXPENSE_DETAILS >
    < EXPENSE_INFO > is < / EXPENSE_INFO >
    < ERROR_CODE > 0 < / ERROR_CODE >
    SUCCESS of < REASON_OF_FAILURE > < / REASON_OF_FAILURE >
    < EXPENSE_LINES >
    < EXPENSE_LINE_REC >
    < EXPENSE_INFO > is < / EXPENSE_INFO >
    < EXPENSE_DATE > 14/12/2012 00:00:00 < / EXPENSE_DATE >
    ABC of < EXPENSE_CODE > < / EXPENSE_CODE >
    HOTEL < EXPENSE_REF > < / EXPENSE_REF >
    < GROSS_AMOUNT > 100 < / GROSS_AMOUNT >
    < > 500 TAX_AMOUNT < / TAX_AMOUNT >
    < ERROR_CODE > 0 < / ERROR_CODE >
    SUCCESS of < REASON_OF_FAILURE > < / REASON_OF_FAILURE >
    < / EXPENSE_LINE_REC >
    < EXPENSE_LINE_REC >
    < EXPENSE_INFO > is < / EXPENSE_INFO >
    < EXPENSE_DATE > 14/12/2012 00:00:00 < / EXPENSE_DATE >
    DEF < EXPENSE_CODE > < / EXPENSE_CODE >
    FILM of < EXPENSE_REF > < / EXPENSE_REF >
    < GROSS_AMOUNT > 10 < / GROSS_AMOUNT >
    < TAX_AMOUNT > 50 < / TAX_AMOUNT >
    < ERROR_CODE > 1 < / ERROR_CODE >
    < REASON_OF_FAILURE > fresh Code does not exist. < / REASON_OF_FAILURE >
    < / EXPENSE_LINE_REC >
    < / EXPENSE_LINES >
    < / EXPENSE_DETAILS >
    < EXPENSE_DETAILS >
    B < EXPENSE_INFO > < / EXPENSE_INFO >
    < ERROR_CODE > 1 < / ERROR_CODE >
    < REASON_OF_FAILURE > Employee Id does not exist. < / REASON_OF_FAILURE >
    < EXPENSE_LINES >
    < EXPENSE_LINE_REC >
    B < EXPENSE_INFO > < / EXPENSE_INFO >
    < EXPENSE_DATE > 14/12/2012 00:00:00 < / EXPENSE_DATE >
    XYZ < EXPENSE_CODE > < / EXPENSE_CODE >
    POINT MILE < EXPENSE_REF > < / EXPENSE_REF >
    < > 200 GROSS_AMOUNT < / GROSS_AMOUNT >
    < > 300 TAX_AMOUNT < / TAX_AMOUNT >
    < ERROR_CODE > 0 < / ERROR_CODE >
    SUCCESS of < REASON_OF_FAILURE > < / REASON_OF_FAILURE >
    < / EXPENSE_LINE_REC >
    < / EXPENSE_LINES >
    < / EXPENSE_DETAILS >
    < / SPENDING >


    I'm not able to generate the XML file. Kindly help me.

    Kind regards
    Sudhanshu

    I love working at the deepest level and then "wrap" with external level tags.

    You want to list all columns of each LINE by line. XMLFOREST is good for this:

    select xmlforest(
      expense_info, expense_date, expense_code, expense_ref,
      gross_amount, tax_amount, error_code, reason_of_failure
    )
    from line;
    
    A
    2012-12-14
    ABC
    HOTEL
    100
    500
    0
    SUCCESS
    ...
    

    Now you want to wrap this up in EXPENSE_LINE_REC

    select xmlelement("EXPENSE_LINE_REC",
      xmlforest(
        expense_info, expense_date, expense_code, expense_ref,
        gross_amount, tax_amount, error_code, reason_of_failure
      )
    )
    from line;
    
    
      A
      2012-12-14
      ABC
      HOTEL
      100
      500
      0
      SUCCESS
    
    

    So far, you have a XML fragment by line in the table of the LINE. You can use XMLAGG to put those together in a single fragment - or rather, a fragment by EXPENSE_INFO.

    Then you use XMLELEMENT again to give the name "EXPENSE_LINES" in this fragment.

    Then you gather the header values and the 'EXPENSE_LINES' fragment in "EXPENSE_DETAILS". This gives you all the information for each row header and associated lines of the LINE.

    Then, you gather all the information into one with XMLAGG header, and give everything a name with XMLELEMENT

    select xmlelement("EXPENSES",
      xmlagg(
        xmlelement("EXPENSE_DETAILS",
          xmlforest(expense_info, a.error_code, a.reason_of_failure),
          xmlelement("EXPENSE_LINES",
            xmlagg(
              xmlelement("EXPENSE_LINE_REC",
                xmlforest(
                  b.expense_date, b.expense_code, b.expense_ref,
                  b.gross_amount, b.tax_amount, b.error_code, b.reason_of_failure
                )
              )
            )
          )
        )
      )
    )
    from header a join line b using(expense_info)
    group by expense_info, a.error_code, a.reason_of_failure;
    

    _Note: _ with the GROUP BY clause, you can 'total' twice, once at the expense_info level and then overall. That's what I do with the two XMLAGGs: the second he puts just all the different stuff EXPENSE_DETAILS together in one package that I wrap "CHARGES" tag autour.

    Also, I omit EXPENSE_INFO of each LINE as it is already in the header information.

    Published by: stew Ashton on December 17, 2012 14:03

  • Remove duplicates from the oracle table using 2 columns

    Hello

    I need to remove the duplicates of an oracle table based on 2 columns in the table.i tried to remove duplicates using the join, but get the error like sql error ora-00933

    Thank you

    Hello

    Here's one way:

    DELETE FROM table_x

    WHERE ROWID NOT IN)

    SELECT MIN (ROWID)

    FROM table_x

    Col_1, col_2

    );

    I hope that answers your question.

    If this isn't the case, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data.

    In the case of a DML operation (for example, REMOVE) the sample data should show what look like the paintings before the DML, and results will be the content of the or the tables changed after the DML.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • Formula 10g to Upload data in an oracle table flat file does not work.

    My files data flat txt looks like this_

    _ "recgis.txt" _


    4300,69, A22110043, TC, 1/17/2009,801100107010100,90,210,2211,0,0,0,0,0,0,0,0,1/17/2009 13:13:46, 131346, 20082009, 1, 1, 0
    4300,69, A22110044, TC, 1/17/2009,801100107010100,60,140,2211,0,0,0,0,0,0,0,0,1/17/2009 13:15:22, 20082009 131522, 0, 1, 0
    4300,69, A22110045, TC, 1/17/2009,801100107010100,210,490,2211,0,0,0,0,0,0,0,0,1/17/2009 13:17:56, 131756, 20082009, 3, 2, 0
    4300,69, A22110046, TC, 1/17/2009,801100107010100,270,630,2211,0,0,0,0,0,0,0,0,1/17/2009 13:19:58, 131958 20082009, 9, 0, 0
    4300,05, A22250013, TC, 1/17/2009,801100107010100,210,490,2225,0,0,0,0,0,0,0,0,1/17/2009 13:21:42, 132142, 20082009, 3, 0, 1
    4300,69, A22110047, TC, 1/17/2009,801100107010100,390,910,2211,0,0,0,0,0,0,0,0,1/17/2009 13:23:31, 132331, 20082009, 1, 6, 0


    _ my control file

    _ "Loader.CTL" _

    load data
    INFILE ' c:\data\REC_GIS. TXT'
    in the REC_GISTEMP table
    fields ended by ',' optionally surrounded "" "
    (TREA_CODE, CHAL_NO, CHAL_DATE, V_NO AND OP_CODE DATE, DEPNAME, ADDRESS, H_CODE, INS_AMT, SAV_AMT,
    SRC_MJCD, MAN_30, MAN_60, MAN_120, MAN_10, MAN_20, MAN_40, MAN_80, MAN_15, ENT_DATE, ENT_TIME, FIN_YEAR, MAN_100, MAN_200, MAN_400)



    * I have created a form and wrote a bellow pl/sql trigger 'WHEN-CLICK' on the download button *.

    DECLARE
    ldrcmd varchar (200);
    BEGIN
    filename: =: BLOCK3. FILEPATH; text box that contains the file path

    ldrcmd: = 'sqlldr control = E:\NIC\UPSEGID\loader.ctl INS/password@orcl';
    Host (ldrcmd);
    END;

    * but its does not work please someone help me what I do wrong... *.

    Published by: 839880 on February 25, 2011 10:26

    Published by: 839880 on February 25, 2011 10:28

    ldrcmd: = 'sqlldr control = log REC_GIS.ctl = upldlog.log INS/password@orcl';

    As stated above, your order is most likely not going to work because of lack of full paths.

Maybe you are looking for

  • I can't start firefox even in safe mode.

    I can't start firefox. It is said that it can not load the profile. The profile files are there, I believer.I can't start firefox even in safe mode, by holding down the SHIFT key.I stopped firefox when he tried to do a refresh (it took a long time).S

  • Equium A210-1AS sometimes stops

    My recently purchased Equium A210-1AS sometimes completely cut and the screen is blank. Someone knows why?

  • WHY NO VIDEO OUTPUTS TV / MONITORS?

    Does anyone know why the televisions and monitors have no VIDEO OUTPUTS of any type?  If anyone is aware of a TV or monitor that has any kind of OUTPUT video integrated (e.g., HDMI or component or composite or S-video or RF/coaxial terminal older typ

  • Is there a unit of different printhead for cartridge 564XL printer B210A Photosmart Photo?

    I recently bought a set of Multipack 564XL ink cartridges for my printer and says black cartridge Photo on it and it is more narrow than the cartridge 564XL black, who is currently in the printer.  Given that I was going to print photos, I tried to i

  • I have a compaq laptop 6735 s.

    has had to replace the hard drive, now, when I start it up it says missing system.was of exploitation running vista but I want to put xp on it... .all assistance.