Select Between two date ranges from xml file

Hi ,
I have a column date_ with datatype VARCHAR2(150) it stores
data as
05/19/2010 11:23 AM
05/20/2010 12:23 PM
05/22/2010 11:23 AM
05/25/2010 11:23 AM
i have to select all the rows between 05/19/2010 and 05/22/2010 how to do that this column is in xml file

I have a table wit two fields
Field1 is integer and field2 is xmltype
in the xmltype i store an xml file
<ParentNode>
<Node>
<Cat>1</Cat>
<Date>05/19/2010 11:23 AM </Date>
</Node>
<Node>
<Cat>2</Cat>
<Date>05/20/2010 12:23 PM </Date>
</Node>
<Node>
<Cat>3</Cat>
<Date>05/22/2010 11:23 AM </Date>
</Node>
</Parentnode>
I am using teh below query to retrive teh result
SELECT T.Feild1, XML.* FROM Tablename T,
XMLTable( 'Parentnod/Node' PASSING T.Feild2 COLUMNS Cat NUMBER PATH 'Cat' ,
DATE_ VARCHAR2(100) PATH 'Date'
)XML where cat >1;
now i have to do teh same to select the rows between two date range 05/19/2010 and 05/21/2010
hope i am able to make teh question simple

Similar Messages

  • Data Load from XML file to Oracle Table

    Hi,
    I am trying to load data from XML file to Oracle table using DBMS_XMLStore utility.I have performed the prerequisites like creating the directory from APPS user, grant read/write to directory, placing the data file on folder on apps tier, created a procedure ‘insertXML’ to load the data based on metalink note (Note ID: 396573.1 How to Insert XML by passing a file Instead of using Embedded XML). I am running the procedure thru below anonymous block  to insert the data in the table.
    Anonymous block
    declare
      begin
      insertXML('XMLDIR', 'results.xml', 'employee_results');
      end;
    I am getting below error after running the anonymous block.
    Error :     ORA-22288: file or LOB operation FILEOPEN failed”
    Cause :   The operation attempted on the file or LOB failed.
    Action:   See the next error message in the error stack for more detailed
               information.  Also, verify that the file or LOB exists and that
               the necessary privileges are set for the specified operation. If
               the error still persists, report the error to the DBA.
    I searched this error on metalink and found DOC ID 1556652.1 . I Ran the script provided in the document. PFA the script.
    Also, attaching a document that list down the steps that I have followed.
    Please check and let me know if I am missing something in the process. Please help to get this resolve.
    Regards,
    Sankalp

    Thanks Bashar for your prompt response.
    I ran the insert statement but encountered error,below are the error details. statement.
    Error report -
    SQL Error: ORA-22288: file or LOB operation FILEOPEN failed
    No such file or directory
    ORA-06512: at "SYS.XMLTYPE", line 296
    ORA-06512: at line 1
    22288. 00000 -  "file or LOB operation %s failed\n%s"
    *Cause:    The operation attempted on the file or LOB failed.
    *Action:   See the next error message in the error stack for more detailed
               information.  Also, verify that the file or LOB exists and that
               the necessary privileges are set for the specified operation. If
               the error still persists, report the error to the DBA.
    INSERT statement I ran
    INSERT INTO employee_results (USERNAME,FIRSTNAME,LASTNAME,STATUS)
        SELECT *
        FROM XMLTABLE('/Results/Users/User'
               PASSING XMLTYPE(BFILENAME('XMLDIR', 'results.xml'),
               NLS_CHARSET_ID('CHAR_CS'))
               COLUMNS USERNAME  NUMBER(4)    PATH 'USERNAME',
                       FIRSTNAME  VARCHAR2(10) PATH 'FIRSTNAME',
                       LASTNAME    NUMBER(7,2)  PATH 'LASTNAME',
                       STATUS  VARCHAR2(14) PATH 'STATUS'
    Regards,
    Sankalp

  • Extracting a count of distinct values between two date ranges over months

    Hi All,
    I am having a bit of difficulty in figuring out the query to build a list of active campaigns over a date range.
    i.e. I have a table with campaign IDs and their start and end date details like this
    Campaign_id     Start_date     End_date
            10001     1-Jun-09     31-May-11
            10002     1-Jun-09     23-Jun-11
            30041     21-Aug-09     31-Dec-09
            20005     3-Jun-10     31-May-11
            90021     21-Nov-09     30-Nov-10
            54000     1-Jun-11     1-Dec-12
            35600     1-Mar-10     31-Mar-12 What the above data means is, for eg. the campaign 10001 is active from 1-Jun-09 to 31-May-11 i.e. for 24 months (inclusive of the month Jun-09 and May-11)
    What I need to figure out is the counts of active campaigns between a date range and display that active count at a month level (for e.g. lets say we want to see all the campaigns that were active
    between the date range '01-JUN-2007' and '30-APR-2012' ). So the partial output would be as seen below. The list would continue till december-2012
    Month    Year    Count of active campaigns
    Jan    2009    0
    Feb    2009    0
    Mar    2009    0
    Apr    2009    0
    May    2009    0
    Jun    2009    2
    Jul    2009    2
    Aug    2009    3
    Sep    2009    3
    Oct    2009    3
    Nov    2009    4
    Dec    2009    4
    Jan    2010    3
    Feb    2010    3
    Mar    2010    4
    Apr    2010    4
    Dec    2012    1 Could anybody please help me with the right query for this.
    Thanks a lot for help
    Regards
    Goldi

    set pagesize 40
    with tab as
                    select 1 id, sysdate -100 start_date, sysdate end_date from dual
                    union
                    select 1 id, sysdate -200 start_date, sysdate -150 end_date from dual
                    union
                    select 1 id, sysdate -600 start_date, sysdate - 400 end_date from dual
                    union
                    select 1 id, sysdate -300 start_date, sysdate - 150 end_date from dual
                    union
                    select 2 id, sysdate -100 start_date, sysdate-50 end_date from dual
          year_tab as
                        select
                                 add_months(min_date, level -1) m
                        from
                                select min(trunc(start_date,'YYYY')) min_date, add_months(max(trunc(end_date,'YYYY')), 12) max_date
                                from tab
                        connect by level <= months_between(max_date, min_date)
    select to_char(m,'YYYY') year_,
             to_char(m,'Month') month_,
             nvl(act, 0) act
    from   year_tab,
                select m date_,count(*)  act
                from tab, year_tab
                where m between trunc(start_date,'MM') and trunc(end_date,'MM')
                group by m
                ) month_tab
    where m = date_(+)
    order by m;
    YEAR_ MONTH_           ACT
    2010  January            0
    2010  February           0
    2010  March              0
    2010  April              0
    2010  May                0
    2010  June               0
    2010  July               0
    2010  August             0
    2010  September          1
    2010  October            1
    2010  November           1
    2010  December           1
    2011  January            1
    2011  February           1
    2011  March              1
    2011  April              0
    2011  May                0
    2011  June               0
    2011  July               1
    2011  August             1
    2011  September          1
    2011  October            2
    2011  November           2
    2011  December           2
    2012  January            2
    2012  February           2
    2012  March              2
    2012  April              1
    2012  May                1
    2012  June               0
    2012  July               0
    2012  August             0
    2012  September          0
    2012  October            0
    2012  November           0
    2012  December           0
    36 rows selected.

  • Select Between Two Dates ELSE

    I can't really seem to get this straightened out.
    SELECT distinct DATE, gross_total_return
    FROM WPI_ICL
    CASE Between '01-01-1980' AND '09-30-2008'
    AND description = 'Broad Market Index United States Property (US Dollar)'
    ELSE
    description = 'S&P United States Property Residential (US Dollar)'
    END
    So, if records are between two dates, select a certain description, ELSE select a different description.  I've tried IF...Then, and I've tried Case too.  So far, nothing has worked out.
    Can someone please give me a point in the right direction?
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    Here's a working example:
    DECLARE @wpi_icl TABLE (date DATE, gross_total_return FLOAT, description1 VARCHAR(100), description2 VARCHAR(100))
    INSERT INTO @wpi_icl (date, gross_total_return, description1, description2)
    VALUES
    ('2008-09-29', 100.0, 'Broad Market Index United States Property (US Dollar)', 'S&P United States Property Residential (US Dollar)'),
    ('2008-10-01', 200.0, 'Broad Market Index United States Property (US Dollar)', 'S&P United States Property Residential (US Dollar)')
    SELECT date, gross_total_return,
    CASE WHEN date BETWEEN '1900-01-01' AND '2008-09-30' THEN description1
    ELSE description2
    END AS description
    FROM @wpi_icl
    From the code you posted, it seems you're unsure of the syntax of CASEs.
    There are two ways to use a case. The first is the example above. You enclose the conditions between CASE and END.
    Each condition has its own WHEN with a clause that evaluates to true or false. This clause can be made up of as many conditions as you like. After the clause comes a THEN. This is essentially what you want to happen if the clause returns true. WHEN/THEN is
    synonymous with IF/THEN in this instance.
    Including an ELSE is optional, but, be aware if you do not, and none of your WHEN clauses evaluate to true, you will have a NULL returned.
    CASE
    WHEN theseDriods = theDriodsWereLookingFor THEN callVader
    WHEN theseDriods <> theDriodsWereLookingFor THEN moveAlong
    ELSE goHomeAndRethinkLife
    END
    The other (less common) option operates like a SWITCH in some other languages. Its still surrounded by CASE and END but this time, the when just contains a value to be compared to the value at the start of the case:
    CASE 16
    WHEN 15 THEN 'too low'
    WHEN 16 THEN 'just right'
    WHEN 17 THEN 'too high'
    END
    Hope this helps.

  • Question about insert date value from xml file

    I want insert value into table from xml file. Every time I inserted value of date type into the table, I got the unpasable error message as following:
    oracle.xml.sql.OracleXMLSQLException: Exception 'java.text.ParseException:Unpars
    eable date: "2000-04-19 00:00:00.0"' encountered during processing ROW element
    Thanks for anyone that can fix my problem or give me any suggestion.
    email: [email protected]

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by matmnwx:
    I want insert value into table from xml file. Every time I inserted value of date type into the table, I got the unpasable error message as following:
    oracle.xml.sql.OracleXMLSQLException: Exception 'java.text.ParseException:Unpars
    eable date: "2000-04-19 00:00:00.0"' encountered during processing ROW element
    Thanks for anyone that can fix my problem or give me any suggestion.
    email: [email protected]<HR></BLOCKQUOTE>
    Use:
    OracleXMLSave sav = new OracleXMLSave(conn,tabName);
    sav.setDateFormat(<hier the date format in the XML-File>);

  • XML data upload from .xml file

    Hi,
    Can anyone let me know is ther any way how I can upload the data from .xml file into Oracle Table.
    Note: I just want to upload the data from xml file; not entire .xml file.
    I have data like as below in test.xml file and I want to upload the data only into TEST_EMP table:
    <?xml version = '1.0'?>
    <ROWSET>
    <ROW num="1">
    <TABLE_NAME>DEPT</TABLE_NAME>
    <TABLESPACE_NAME>USERS</TABLESPACE_NAME>
    </ROW>
    <ROW num="2">
    <TABLE_NAME>EMP</TABLE_NAME>
    <TABLESPACE_NAME>USERS</TABLESPACE_NAME>
    </ROW>
    <ROW num="3">
    <TABLE_NAME>BONUS</TABLE_NAME>
    <TABLESPACE_NAME>USERS</TABLESPACE_NAME>
    </ROW>
    <ROW num="4">
    <TABLE_NAME>SALGRADE</TABLE_NAME>
    <TABLESPACE_NAME>USERS</TABLESPACE_NAME>
    </ROW>
    <ROW num="5">
    <TABLE_NAME>BHAVESH_EMP</TABLE_NAME>
    <TABLESPACE_NAME>USERS</TABLESPACE_NAME>
    </ROW>
    </ROWSET>
    Any help would be highly appreciated!!
    Thanks... Bhavesh

    One way is to use sql* loader...
    http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb25loa.htm

  • Function module to calculate no of days between two date ranges

    hi experts,
    can some one please suggest a function module that can calculate no of days between specified date range.
    for example : if i enter date range between 26.02.2011 to 20.05.2011, then it should calculate no of days between these dates.
    Moderator message : Basic date questions not allowed. Read forum rules before posting. Thread locked.
    Edited by: Vinod Kumar on May 25, 2011 10:57 AM

    Hi,
    Please search SDN.. there are lots of posts for teh same.
    [http://wiki.sdn.sap.com/wiki/display/ABAP/FunctionModulerelatedonDate+calculations]

  • Oracle 8i - select between to date ranges, but exculde time ranges

    Hi, I'm using Oracle 8i
    I'm trying to select a set of records that are between a certain date time (say between October 15 at 6pm and October 17 at 6am) and then want to include only those records that fall between 6am and 6pm within the range.
    I've tried extract and trunc function and can't seem to get it to work.
    If I do a trunc to try to pull out only hour, it returns all of the date information as well:
    SQL> select trunc(to_date('14-10-2007 02:43:46','DD-MM-YYYY HH24:MI:SS'),'HH24') from dual;
    TRUNC(TO_DATE('14-10
    14-OCT-2007 02:00:00
    SQL>Any Ideas? Here is some sample data:
    select * from
            select to_date('14-10-2007 02:43:46','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('14-10-2007 03:02:50','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('14-10-2007 15:13:16','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('14-10-2007 15:16:04','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('14-10-2007 15:18:26','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('14-10-2007 15:20:25','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('14-10-2007 15:22:35','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('14-10-2007 15:23:59','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('14-10-2007 15:26:30','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('14-10-2007 15:33:30','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('14-10-2007 15:54:36','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('14-10-2007 15:56:11','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('14-10-2007 18:56:52','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('15-10-2007 09:12:38','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('15-10-2007 10:23:42','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('15-10-2007 11:17:32','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('15-10-2007 11:46:12','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('15-10-2007 12:36:22','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('15-10-2007 23:23:17','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('16-10-2007 14:43:06','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('16-10-2007 14:44:37','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('16-10-2007 14:48:17','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('16-10-2007 14:49:36','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('16-10-2007 15:07:05','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('16-10-2007 15:08:24','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('17-10-2007 08:55:33','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('17-10-2007 09:58:19','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('17-10-2007 15:07:16','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('17-10-2007 15:19:35','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('17-10-2007 15:58:32','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('17-10-2007 19:56:51','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('17-10-2007 21:22:49','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('17-10-2007 22:16:52','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('17-10-2007 22:45:51','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('18-10-2007 07:52:10','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('18-10-2007 07:54:15','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('18-10-2007 08:03:57','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('18-10-2007 08:31:27','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('18-10-2007 09:16:14','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('18-10-2007 11:10:55','DD-MM-YYYY HH24:MI:SS') from dual union all
            select to_date('18-10-2007 11:21:57','DD-MM-YYYY HH24:MI:SS') from dual
    ) DataSet

    If you can subtract date types from each other in 8i (I think you can but don't know for sure) you can use this:select dte, (dte-trunc(dte))*24 hours
    from (SELECT TO_DATE('15-10-2007 05:59:59',    'DD-MM-YYYY HH24:MI:SS') DTE FROM DUAL UNION ALL
       SELECT TO_DATE('15-10-2007 06:00:00',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('15-10-2007 06:00:01',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('15-10-2007 17:59:59',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('15-10-2007 18:00:00',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('15-10-2007 18:00:01',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('16-10-2007 05:59:59',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('16-10-2007 06:00:00',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('16-10-2007 06:00:01',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('16-10-2007 17:59:59',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('16-10-2007 18:00:00',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('16-10-2007 18:00:01',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('17-10-2007 05:59:59',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('17-10-2007 06:00:00',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('17-10-2007 06:00:01',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('17-10-2007 17:59:59',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('17-10-2007 18:00:00',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL UNION ALL
       SELECT TO_DATE('17-10-2007 18:00:01',    'DD-MM-YYYY HH24:MI:SS') FROM DUAL
       ) t
    where dte between TO_DATE('15-10-2007 18:00:00',    'DD-MM-YYYY HH24:MI:SS')
                  and TO_DATE('17-10-2007 06:00:00',    'DD-MM-YYYY HH24:MI:SS')
          and (dte-trunc(dte))*24 between 6 and 18
    DTE                       HOURS                 
    15-OCT-2007 18.00.00      18                    
    16-OCT-2007 06.00.00      6                     
    16-OCT-2007 06.00.01      6.00027777777777777777777777777777777778
    16-OCT-2007 17.59.59      17.99972222222222222222222222222222222222
    16-OCT-2007 18.00.00      18                    
    17-OCT-2007 06.00.00      6                     
    6 rows selected

  • Extract data from XML file to Oracle database

    Dear All
    Please let me know, how to extract data from XML file to Oracle database which includes texts & images.
    Thanking You
    Regards Lakmal Marasinghe

    I would do it from the database, but then again, I am a database / PL/SQL guy.
    IMHO the database will deliver you with more options. I don't know about "speed" between the two.

  • Load data from XML files into BI

    Hi All,
    Can any one guide me through the steps which involve in loading data from XML files into BI?
    Thanks
    Santosh

    Hi James,
    I have followed upto step No: 12 .
    Please could you let me know how to link the XML file on my local drive to BI,
    I am not able to find figure out where to specify the path of the XML file to be loaded into BI.
    Thanks In Advance
    Regards,
    San
    1. Create a Infosource(ZIS), with transfer structure in accordance with the structure in the XML file. (You can open the XML file with MS Excel.This way you can get to know the structure).
    2. Activate the transfer rules.
    3. After activation ;from the Menu Bar , Select Extras>Create BW Datasource with SOAP connection.
    4.Now Activate the Infosurce again, this creates an XML based Datasource(6AXXX...)
    5.These steps would create two sub nodes under the Infosource(ZIS).
    6.Select Myself system and create a data package and execute it run in Init mode(without Data Transfer).
    7. This would create an entry in RSA7(BW delta Queue)
    8. Again create another Delta Infopackage under it, and run it. Now the Datasource(6AXXXXXX..) would turn green in RSA7.
    9.In Function builder(SE37) select your FM( do a search ,F4, on the datasource 6AXXX....) .
    10.Inside this RFC based FM , from the Menu Bar select Utilities>more Utilities>Create Web services>From Function module.
    11.A wizard will guide you through the next steps .
    12.once this is done a Web serrvice would be enabled in WSADMIN. Select your FM and execute it.
    13.From here you can upload the data from XML file into BW delta queue.
    Edited by: Santosh on Nov 30, 2008 2:22 PM

  • How to export a data as an XML file from oracle data base?

    could u pls tell me the step by step procedure for following questions...? how to export a data as an XML file from oracle data base? is it possible? plz tell me itz urgent requirement...
    Thankz in advance
    Bala

    SQL> SELECT * FROM v$version;
    BANNER
    Oracle DATABASE 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS FOR 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    5 rows selected.
    SQL> CREATE OR REPLACE directory utldata AS 'C:\temp';
    Directory created.
    SQL> declare                                                                                                               
      2    doc  DBMS_XMLDOM.DOMDocument;                                                                                       
      3    xdata  XMLTYPE;                                                                                                     
      4                                                                                                                        
      5    CURSOR xmlcur IS                                                                                                    
      6    SELECT xmlelement("Employee",XMLAttributes('http://www.w3.org/2001/XMLSchema' AS "xmlns:xsi",                       
      7                                  'http://www.oracle.com/Employee.xsd' AS "xsi:nonamespaceSchemaLocation")              
      8                              ,xmlelement("EmployeeNumber",e.empno)                                                     
      9                              ,xmlelement("EmployeeName",e.ename)                                                       
    10                              ,xmlelement("Department",xmlelement("DepartmentName",d.dname)                             
    11                                                      ,xmlelement("Location",d.loc)                                     
    12                                         )                                                                              
    13                   )                                                                                                    
    14     FROM   emp e                                                                                                       
    15     ,      dept d                                                                                                      
    16     WHERE  e.DEPTNO=d.DEPTNO;                                                                                          
    17                                                                                                                        
    18  begin                                                                                                                 
    19    OPEN xmlcur;                                                                                                        
    20    FETCH xmlcur INTO xdata;                                                                                            
    21    CLOSE xmlcur;                                                                                                       
    22    doc := DBMS_XMLDOM.NewDOMDocument(xdata);                                                                           
    23    DBMS_XMLDOM.WRITETOFILE(doc, 'UTLDATA/marco.xml');                                                                  
    24  end;                                                                                                                  
    25  /                                                                                                                      
    PL/SQL procedure successfully completed.
    .

  • Select Query Between two dates...

    Hi Guru's,
    I need a Select Query between two dates, also if the record not found for any in between date then it should return NULL or 0 ...
    for Example
    1. I am having two records in DB for date 2-10-2008 & 4-10-2008
    2. Now suppose I have given Query for date between 1-10-2008 to 5-10-2008
    Then it should return me 5 records with valid values for 2 & 4 and NULL for other 1,3,5
    Thanks.

    Try like this:
    with
      t as
          select date '2008-10-02' as dt, 'Record #1 (in DB)' as str from dual union all
          select date '2008-10-04' as dt, 'Record #2 (in DB)' as str from dual
    select v.dt, t.str
      from (
             select date '2008-10-01' + level - 1 as dt
               from dual
             connect by level <= (date '2008-10-05' - date '2008-10-01') + 1
           ) v
      left join t
        on v.dt = t.dt
    order by 1

  • Hi, extract data from xml file and insert into another exiting xml file

    i am searching code to extract data from xml file and insert into another exiting xml file by a java program. I understood it is easy to extract data from a xml file, and how ever without creating another xml file. We want to insert the extracted data into another exiting xml file. Suggestions?
    1st xml file which has two lines(text1.xml)
    <?xml version="1.0" encoding="iso-8859-1"?>
    <xs:PrintDataRequest xmlns:xs="http://com.unisys.com/Anid"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://com.unisys.com/Anid file:ANIDWS.xsd">
    <xs:Person>
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://com.unisys.com/Anid file:ANIDWS.xsd">
    These two lines has to be inserted in the existing another xml(text 2.xml) file(at line 3 and 4)
    Regards,
    bubbly

    Jadz_Core wrote:
    RandomAccessFile? If you know where you want to insert it.Are you sure about this? If using this, the receiving file would have to have bytes inserted that exactly match the number of bytes replaced. I'm thinking that you'll likely have to stream through the second XML with a SAX parser and copy information (or insert new information) as you stream with an XML writer of some sort.

  • Select entries between two dates by converting Unix timestamp in Oracle Dat

    Hi,
    I need to select the entries between two dates from an Oracle db. The Oracle db has a column with Unix timestamps. I use the following querry, but it doesnt seem to be working as desired.
    select count(*) from reporter_status where to_char(FIRSTOCCURRENCE, 'mm-dd-yy') between ('08-07-06') and ('08-08-06');
    FIRSTOCCURRENCE has the Unix timestamps.
    Could anyone help me out with this. Thank you for your help.

    Assuming that it is actually a UNIX timestamp, then it is the number of seconds since Jan 1, 1970, so you need something like:
    SELECT COUNT(*)
    FROM reporter_status
    WHERE TO_DATE('01-Jan-1970', 'dd-mon-yyyy') + (firstoccurrence/24/60/60)
                    BETWEEN TO_DATE('08-07-2006', 'mm-dd-yyyy') AND
                            TO_DATE('08-08-2006, 'mm-dd-yyyy');Did Y2K not teach us anything? Use 4 digit years.
    John

  • Find gap between two dates from table

    Hello All,
    I want to find gap between two dates ,if there is no gap between two dates then it should return min(eff_dt) and max(end_dt) value
    suppose below data in my item table
    item_id    eff_dt           end_dt
    10         20-jun-2012     25-jun-2012
    10         26-jun-2012     28-jun-2012 There is no gap between two rows for item 10 then it should return rows like
    item_id eff_dt end_dt
    10 20-jun-2012 28-jun-2012
    item_id    eff_dt           end_dt
    12         20-jun-2012     25-jun-2012
    12         27-jun-2012     28-jun-2012 There is gap between two rows for item 12 then it should return like
    item_id eff_dt end_dt
    12 20-jun-2012 25-jun-2012
    12 27-jun-2012 28-jun-2012
    I hv tried using below query but it giv null value for last row
    SELECT   item_id, eff_dt, end_dt, end_dt + 1 AS newd,
             LEAD (eff_dt) OVER (PARTITION BY ctry_code, co_code, item_id ORDER BY ctry_code,
              co_code, item_id) AS LEAD,
             (CASE
                 WHEN (end_dt + 1) =
                        LEAD (eff_dt) OVER (PARTITION BY ctry_code, co_code, item_id ORDER BY ctry_code,
                         co_code, item_id, eff_dt)
                    THEN '1'
                 ELSE '2'
              END
             ) AS new_num
      FROM item
       WHERE TRIM (item_id) = '802'
    ORDER BY ctry_code, co_code, item_id, eff_dtI m using oracle 10g.
    please any help is appreciate.
    Thanks.

    Use start of group method:
    with sample_table as (
                          select 10 item_id,date '2012-6-20' start_dt,date '2012-6-25' end_dt from dual union all
                          select 10,date '2012-6-26',date '2012-6-26' from dual
    select  item_id,
            min(start_dt) start_dt,
            max(end_dt) end_dt
      from  (
             select  item_id,
                     start_dt,
                     end_dt,
                     sum(start_of_group) over(partition by item_id order by start_dt) grp
               from  (
                      select  item_id,
                              start_dt,
                              end_dt,
                              case lag(end_dt) over(partition by item_id order by start_dt)
                                when start_dt - 1 then 0
                                else 1
                              end start_of_group
                        from  sample_table
      group by item_id,
               grp
      order by item_id,
               grp
       ITEM_ID START_DT  END_DT
            10 20-JUN-12 26-JUN-12
    SQL> SY.

Maybe you are looking for

  • Can you please help fix this Update rule?

    Hi, I have a field (field1) in an ODS (ODS1) and the same field1 is also in ODS2. Once ODS2 is loaded with data, I would like to populate the same field1 in ODS1 through the UPDATE RROUTINE. So I went to ODS1 and in the update rules, selected field1,

  • Make invoice with item level only not by batch level

    Hii i made a delivery doc say material 'A' having batch1,batch2,batch3 with different qty . exp:(VL03N) material a batch1 10ton material a batch2 20ton material a batch3 30ton Now i wanted to club all this qty and do invoice with single item for 'Mat

  • How can I edit movies in iTunes?

    I have some Youtube movies in iTunes that I would like to shorten a little but when I try to open the export in iMovie I cannot. What format do I need to be able to do this? Thanks, Richard

  • Need help building an autonomy formula, able to self-arrange itself

    Hi again, folks! I've recently been helped by Barry in some of my problems with Numbers and formulas, and he helped me a lot, but I need a new help. Please, notice that I have no idea about spreadsheets, mathematics and such, but a creative mind As w

  • Migrating date from old iMac to G5 iMac

    I need to migrate a friend's WordPerfect files and Netscape email files from an older blue iMac on OS 9 to a G5 iMac on OS 10.3. I have read the relevant Knowledge Base items. I plan to connect the two computers with a ethernet cable to form a simple