Generate calendar from data

Hi all, i have a problem with a query. i will make this two parts. the first part is describe below. the second part will be discuss in follow up posts. i am using oracle 9.2.0.7 enterprise
i have two tables
CREATE TABLE t2 (id NUMBER, dt DATE, src NUMBER);
ALTER TABLE t2 ADD PRIMARY KEY(id,dt,src);
CREATE TABLE year_calendar(id NUMBER, dt DATE);
ALTER TABLE year_calendar ADD primary_key(id,dt)
and i have data on them. you can download the files from this link and loaded using sql loader
http://lavainita.webatu.com/files/flat/Downloads.zip
note: t2 has 185,000 rows data looking a the file. but if you would like you can duplicate the data so that it reaches 1.5 million
but the duplication should have different src number. i am interested in 59
the problem is that i am trying to generate a calendar (kind of)
year_calendar has dates on them. i am interesting on the dates for id 42
t2 table has dates that are one week apart and sometimes month end dates.
for example, for id 557267 and src=59 i have data such as
557267 1/27/2009
557267 2/3/2009
557267 3/3/2009
557267 3/31/2009
and so on
what i want to do is join t2 with year_calendar and generate some sort of calendar. so for example, the output should be something like
557267 1/27/2009
557267 1/28/2009 --taken from calendar table
557267 1/29/2009 -- same as above
....so on
557267 2/3/2009
557267 2/4/2009
... so on
i have the following query that does this but it is running kind of slow. takes a few minutes to complete
WITH t1 AS (
SELECT     id, dt
     ,     LEAD (dt, 1, dt+1) )
          OVER ( PARTITION BY id ORDER BY dt)          AS next_dt
     FROM     t2 WHERE src=59
SELECT b.dt,
ratings2.id
     FROM     (SELECT * FROM t1)ratings2 ,year_calendar b
WHERE b.dt >= ratings2.dt
          AND     b.dt < ratings2.next_dt
AND b.id=42
does anybody know how to tune this query or create another query that does the same thing(join t2 with year_calendar and generate a calendar) please note: id in year calendar is not related to id in t2. they mean different thing
Edited by: user12852540 on Apr 1, 2010 11:10 AM

Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('01/27/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('01/28/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('01/29/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('01/30/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('01/31/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('02/01/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('02/02/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('02/03/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('02/04/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('02/05/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('02/06/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('02/07/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into year_calendar
(id, dt)
Values
(42, TO_DATE('02/08/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into t2
(id, dt, src)
Values
(557267, TO_DATE('01/27/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 59);
Insert into t2
(id, dt, src)
Values
(557267, TO_DATE('02/03/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 59);
output should be
557267 1/27/2009
557267 1/28/2009
557267 1/29/2009
557267 1/30/2009
557267 1/31/2009
557267 2/1/2009
557267 2/2/2009
557267 2/3/2009
of course, any query will run fast with this amount of data. if you load the file i provided and run query on it, then you will see that it runs slower. query should give the output above

Similar Messages

  • Generating graph from data in File

    Hi ,
    I have a 100000 entries inf a file of the of the form :
    X Y
    5 421452334
    8 2547687676
    3 3454676
    From this data, I want to generate a graph. Would someone please suggest
    how should I generate this type of graph in Java ?
    Thank.
    Sachin

    ... or if it's a different type of graph you're talking about, have a look at JGraph:
    [http://www.jgraph.com/jgraph.html]

  • Remove spaces when generating xml from data mapped on object types

    My problem is kind of complex so I'll try to reduce it to a more manageable example:
    drop type msm force;
    drop type list_msm force;
    create type msm as object(
         nume char(20)
    create type list_msm as table of msm;
    select xmlserialize (document xmlelement("values",
         cast(multiset(
              select trim(p.den) from produse p) as list_msm
         ) as clob indent size=2
         ) as "xml"
         from dual;
    This is where it gets tricky.
    p.den is a field that contains spaces. I use trim(p.den) to remove them but because I cast this to list_msm, the values are then again mapped into msm objects, which have the "nume" field of char(20). So.. when generating the XML, the output still contains spaces.
    This is an excerpt of the result:
    <values>
    <LIST_MSM>
    <MSM>
    <NUME>Prod.1 </NUME>
    </MSM>
    <MSM>
    <NUME>Prod.2 </NUME>
    </MSM>
    <MSM>
    <NUME>Prod.3 </NUME>
    </MSM>
    <Later.. I see that the forum removes the extra spaces but I ensure you that after eg. "Prod.1" there are a lot of spaces, as the original field from the "produse" table is defined as char(20))
    So.. Is there a way to generate the XML without those extra spaces? Basically, I want to be able to trim them before I send them to the xml serializer, but the problem is that i have no control over the whole casting thing ( oracle magic happening that automatically creates all the xmlelements needed, etc.)
    Somehow, when the xml engine steps over the collection and accesses the fields, somehow, i need a trim there. Maybe some kind of accesor for the fields in the type can be declared so that the xml engine uses it instead of the field itself directly. The accesor would then return trim(field). Sorry for this mumbo jumbo gibberish but I want to be as clear as possible.
    Edited by: user9229988 on May 10, 2012 9:24 AM
    Edited by: user9229988 on May 10, 2012 9:25 AM
    Edited by: user9229988 on May 10, 2012 9:38 AM

    Hi.
    Check this:
    drop type msm force;
    drop type list_msm force;
    create type msm as object(
    nume VARchar2(20)     --VARCHAR2 NOT CHAR
    create type list_msm as table of msm;
    create table produse
    den char(20)
    INSERT INTO produse VALUES('Prod.1');
    INSERT INTO produse VALUES('Prod.2');
    INSERT INTO produse VALUES('Prod.3');
    COMMIT;
    select xmlserialize (document xmlelement("values",
    cast(multiset(
    select trim(p.den) from produse p) as list_msm
    ) as clob indent size=2
    ) as "xml"
    from dual;
    <values>
      <LIST_MSM>
        <MSM>
          <NUME>Prod.1</NUME>
        </MSM>
        <MSM>
          <NUME>Prod.2</NUME>
        </MSM>
        <MSM>
          <NUME>Prod.3</NUME>
        </MSM>
      </LIST_MSM>
    </values>Hope this helps.

  • How to generate XML from relational data : PL/SQL or Java

    I'm new to Oracle XML and would appreciate some advice. I've been asked to generate XML documents from data stored in relational tables. The XML documents must be validated against a DTD. We will probably want to store the XML in the database.
    I've seen a PL/SQL based approach as follows :
    1.Mimic the structure of the DTD using SQL object types 2.Assign the relational data to the object type using PL/SQL as required
    3.Use the SYS_XMLGEN package to render the required XML documents from the SQL objects
    However, creating the object types seems to be quite time consuming (step 1 above) for anything other than the simplest of XML documents.
    I've also seen that there is the Java based approach, namely :
    1. Use the XML generator to build Java classes based on a DTD.
    2. Use these classes to build the required XML
    On the face of it, the Java based approach seems simpler. However, I'm not that familiar with Java.
    Which is the best way to proceed ? Is the PL/SQL based approach worth pursuing or should I bite the bullet and brush up my Java ?
    Is it possible to use a combination of PL/SQL and Java to populate the dtd generated java classes (step 2 of the Java approach) to reduce my learning curve ?
    Thanks in advance

    To help answer your questions:
    1) Now, in 9iR2, you can use SQL/XML as another choice.
    2) You can also use XSU to generate the XML and use XSLT to transform it to a desired format instead of using object views if possible.
    3) XDK provide Class generator support to populate XML data to Java classes.

  • How to generate a report from data entered by users in XML forms

    hi,
      i have a requirement to generate report from xml forms which are created using XML forms Builder and stored in Km folders. management want to see in a single report all the activities of all the users in the xml form in such a way that one row in the report presents data blongs to each user.  i have no idea regarding this.
    can any one help me in detail.
    Thanking you in adavance
    sajeer

    Hi Sajeer,
    You have given quite few information what data should be collected / showed in detail. Anyhow, it sounds as if you want to provide data which isn't provided within the standard portal so far (see http://help.sap.com/saphelp_nw2004s/helpdata/en/07/dad131443b314988eeece94506f861/frameset.htm for a list of existing reports).
    For your needs you probably have to develop a repository service which reacts on content / property changes and then you would have to log these changes somewhere, for example in a DB. On the other side, you then could implement a report iView which accesses this data and displays it as whished.
    Hope it helps
    Detlev
    PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance!

  • EBS-R12 Generate XML (with data) from Embedded Data Definition

    Hi
    I'm new to running XMLP/BIP in EBS.
    I have found the extensive set of data definitions and templates in EBS and they work great out of the box.
    I, however, need to make template modifications.
    To this end, a correctly structured XML data template - containing all the data fields - is needed for loading into the template-builder in Word.
    If for example I take the embedded R12 data definition - XLAJELINESRPT.xml - for Posted Payable Invoices, and load it into the template builder, it provides the structure of the data template and not the structure of the output XML data.
    I have tried several ways to run the Data definition through XMLP using the concurrent manager attempting to intercept the generated XML (with data) but it either completes the process and uses the linked output template - producing the PDF - or other output - or if I remove the (output template altogether) it fails with an error.
    Maybe I'm missing an obvious step, but there has to be a way of taking the very comprehensive Data Definitions embedded in R12 EBS and using them in custom report templates.
    If I've totally missed the point, please give me the steps to follow.
    Many thaks in anticipation.
    Mike MacMurray

    HI Mike,
    You cannot load your Data Template into the MS Word Template Builder plugin, as it cannot be run to generate XML this way.
    You have two options to get the data from an XML Publisher Report run as a concurrent program in EBS.
    1) Using the XML Publisher Administrator responsibility, set an end date for both the Data Defintion and Template Definitions associated with the XLAJELINESRPT report.
    2) Leave the concurrent program, Data Defintions and Template Definitions exactly as they are and run the report. Once the report has completed, select the Concurrent Request, click "Diagnostics" then click "View XML". This will open the XML in a new browser window. You can then right click, View Source and then save this document locally.
    You can then load this XML into the MS Word Template Builder and start building your template.
    I hope this helps.
    Regards,
    Cj

  • I wish to generate reports from the database an out put it but i need to enter a date from and to ina  html input box

    i wish to generate reports from the database an out put it
    but i need to enter a date from and to ina html input box
    in the input box a data of range will be input from a start
    to latest
    latest being the default as today's date.
    any help tips snipplets, concepts , turot=rails.
    thanks

    easycfm.com has tutorials for people who are brand new.
    If you don't know much about sql, I have heard good things
    about the book, Teach Yourself SQL in 10 Minutes by Ben
    Forta.

  • How do I restore calendar from earlier date?

    I removed calendars from my view, not knowing that it removed the calendar data itself.  Is their anyway to retrieve that data?

    Only through itunes.
    When you have the itunes panel up.
    On the LH side panel where the device appears, if it doesn't then yourv'e got problems.
    When you see the device, two finger click on it and a sub menu dialogue block appears with options.
    Press the desired option to get to the main dialogue control panel and proceed from there.

  • Query displaying from date & to date selected from calendar

    Hello every1,
    I just want to create a query which will display from date and to date which i need to select it from the calendar.
    Can any1 help me out for it.

    HELLO,
    ACTUALLY I HAVE A FIELD CALLED DUE DATE IN MY UDT WHERE I HAVE ENETERED  SOME MY DUE DATES. NOW WHEN IAM CREATING A QUERY FOR DUE DATE AS FOLLOW:
    SELECT * FROM DBO.[@LC_OV_H]  T0 WHERE T0.DUEDATE>='[%0]' AND T0.DUEDATE<='[%1]'
    IT IS GIVEN ME A LIST OF THE DUE DATES WHICH I HAVE ENTERED BUT HERE I WANT A CALENDER TO BE DISPLAYED DURING SELECTION.........
    Edited by: MEGHSHILPK on Jul 17, 2010 10:07 AM

  • Grabbing an event from a specific calendar by date

    Is there a way to grab an event from a specific calendar by date?
    Basically, I receive an email with information I want to put in the event name (title?) - it is in a particular calendar, and a on a particular date. I grab that event, update the event title with the information i parsed from the email message (i've already got that part done).
    I've looked through many applescript examples, but they all seem to deal with creating an event, not updating one.

    It's quite easy if you know specific value of the event, the following change summary property of the event:
    tell application "iCal"
    set _event to first event of calendar "Home" whose summary contains "Test..."
    set summary of _event to "More Test..."
    reload calendars
    end tell
    However, things get complicated when you try to get repeated events, because repeat events don't really have true start date and end date. So it's really difficult to get a repeat event by its start date or end date. See this thread:
    http://discussions.apple.com/thread.jspa?threadID=440481&tstart=0

  • Synchronized my iPhone 3G 8G to copy the contacts and calendars from Outlook, I wonder if I can do the same synchronization to copy the same data from Gmail

    Synchronized my iPhone 3G 8G to copy the contacts and calendars from Outlook, I wonder if I can do the same synchronization to copy the same data from Gmail ?

    Right, I finally managed to get it sorted out.
    iCloud only accept version 3.0 vcards, and the one I was using were version 2.1 so that's why it wasn't picking it up. So the easy way to get that sorted out is, use a gmail account.
    I know you don't wanna do it because you think it's too much hassle and stuff, but trust me it only takes 5 minutes and that's it.
    1. Create a Gmail Account.
    2. Export your Old VCard files to the Gmail Account.
    3. Now Import them from Gmail to your PC again.
    And, that's it, that's just makes the new imported version in 1 file contains your all contacts in version 3.0. Now you can just upload that on icloud and then sync it with your iphone.
    That's what I did and it worked, and I am sure if you wanna replace this file in the Contacts folder under your User Account in Windows and then try to sync Contacts in Tunes, it should work, but as I said, I did it with iCloud and it worked for me. So aye, that's pretty much it. Phewwww..
    Been searching for it for the whole day and it took 5 minutes in the end, badass...
    Anyway, don't lose hope and always Google for everything!

  • How to add doctype when generating XML from an arbitrary data structure

    I was reading SUN's tutorial "Working with XML - PART IV: Using XSLT". Inside this tutorial, in 3, it talks about how to generate XML from an arbitrary data structure making use of a XMLReader and a Transformer. The example only shows adding elements. Is there a way to add DTD information in the XML generated, i.e. <!DOCTYPE ... >? What APIs can I use?
    Thanks,
    Alex

    The simplest way seems to me is to use a XSL file for that. The <xsl:output> attributes doctype-system and doctype-public generate the DTD declaration <!DOCTYPE YOUR_ROOT SYSTEM "yourDTDfile.dtd"> and <!DOCTYPE YOUR_ROOT PUBLIC "yourDTDfile.dtd">, respectively.
    When calling transformerInstance.transform() the XSLT processor performs the identity transformation - it just copies elements, attributes, content, processing instructions and comments to the result stream.
    If you're using an xsl file for your transformation already, simply add <xsl:output doctype-system="yourDTDfile.dtd"/> to your existing XSL file.
    If you're only using the identity transformation you'd need to change the line of code where you obtain the transformer instance from the TransformerFactory to:
    t_factory.newTransformer(new StreamSource("test.xsl"));
    and use this as test.xsl:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output doctype-system="yourDTDfile.dtd"/>
       <!-- this is the identity transformation -->
       <xsl:template match="*|@*|comment()|processing-instruction()|text()">
          <xsl:copy>
             <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
          </xsl:copy>
       </xsl:template>
    </xsl:stylesheet>Good luck.

  • TS4062 Why won't my outlook calendar show data from my iPhone calendar after synching.

    Why won't my outlook calendar show data from my iPhone calendar after synching?

    I have the same problem - between the issue I had with restoring after the upgrade (Error -48), the duplicate entries I now get between my Outlook appointments and iCloud, and the inability to have Events added from the iPhone sync to Outlook, I'm surprised there hasn't been more outcry about 5.0x! Not to mention the battery problem, which I HOPE they ironed out.

  • Generate report with data from database package

    Hi
    Is it possible to generate a report where the values come from an oracle database package instead of from an sql query declared in the report itself?
    If yes, how is it done?
    Appreciate any help. Thx.

    Hi,
    You can use REF CURSORs to generate reports from a database package.
    For information about REF CURSORs, please see Chapter 40 'Building a Paper Report with REF CURSORs' of the Oracle Reports Building Reports manual.
    This chapter is at:
    http://download-uk.oracle.com/docs/html/B13895_01/orbr_refcur.htm#i1011693
    Hope this helps.
    Regards,
    Panna

  • Can not get my calendar from my iPhone to sync with my mac at home I have up to date software and ICloud?  What am I doing wrong?

    I am trying to sync my calendar from my Iphone to my mac at home.  It wont show any of the work calendar entries.  All the entries from my home show up fine on both.  I have Icloud so dont know what I am doing wrong?

    maybe this link will help http://www.makeuseof.com/answers/play-media-files-mac-formatted-external-hard-dr ive-hdtv/ unfortunately its for file up to 4 GB size, otherwise try to connect your mac directly to your Tv or I suggest contacting SAMSUNG about this issue, maybe the have assigned softwares for this formatting issues like in western digital for example.

Maybe you are looking for

  • Sub total from group by query?

    Hi, im using oracle 9i. Im getting results fine for the following kind of query,    select a,b,c,sum(qty) d,sum(val) e from my_table group by a,b,c    Now the output look like this a     b     c     d     e 1     tt     rr     10     15 1     tt     

  • [h]:mm:ss how can i get this format in report

    Hello Gurus,     I am creating a report in BEx and have to sum up HH:MM:SS column.I am facing problem while the sum is more then 24 hours. The custom format of excel[h]:mm:ss helps in getting the the total of HH:MM:SS even if the total is more then 2

  • Does anyone deploy 10.1.3 applications (adf & toplink) in websphere 6.0?

    does anyone deploy 10.1.3 applications (adf & toplink) in websphere 6.0? We are migrating the Jdev code to 10.1.3 and make some more development. do any of you deploy 10.1.3 in websphere 6.0? Thanks

  • I wish to teach Java, but may need some help

    Hi, I teach Junior High, and since no formal programming class exists, I have made a programming club. We have spent the last while doing some mindless tech work, but now I want to get them bitting their teeth on Java. I taught it a few years ago, so

  • Re: NT Deplyment error message

    Greg Fuller wrote: > Has anyone seen this error message and better yet have a solution. [email protected] SYSTEM ERROR: Unable to complete partitioning. There may be unassigned service objects. Class: qqsp_ErrorDescriptor Error Time: Wed Aug 13 14:40