How to make a function out of a query

Hi,
I have the following query:
select
to_date(sysdate, 'DD.MM.YYYY') as "FULL_DATE",
to_number(to_char(sysdate, 'D')) as "DAY_OF_WEEK",
to_number(to_char(sysdate, 'DD')) as "DAY_NUMBER_IN CALENDAR_MONTH",
to_number(to_char(sysdate, 'DDD')) as "DAY_NUMBER_IN CALENDAR_YEAR"
from
dual
how to I make a funtion where I can input a start and an ending date and it calculates allt the rows fow the days in between?
Thanks,
Walter

drop type mytabletype;
create or replace type mytype as object (
full_date date,
dow number,
daynum_m number,
daynum_y number
create or replace type mytabletype as table of mytype;
create or replace function myfunc (p_date in date) return mytabletype pipelined as
  cursor cur_mycur is
  select
    to_date(p_date, 'DD.MM.YYYY') as "FULL_DATE",
    to_number(to_char(p_date, 'D')) as "DAY_OF_WEEK",
    to_number(to_char(p_date, 'DD')) as "DAY_NUMBER_IN_CALENDAR_MONTH",
    to_number(to_char(p_date, 'DDD')) as "DAY_NUMBER_IN_CALENDAR_YEAR"
    from dual;
  x mytype := mytype(null,null,null,null);
begin
  for i in cur_mycur
  loop
    x := mytype(i.full_date,i.day_of_week,i.day_number_in_calendar_month,i.day_number_in_calendar_year);
    pipe row(x);
  end loop;
end;
sho err
select * from table(myfunc(sysdate));
select * from table(myfunc(to_date('15/09/2006','dd/mm/yyyy')));is this what you're after.
If so I suggest you take it away, and get an understanding for it. It's a very useful technique to know.
I know it doesn't do all the days between 2 dates, but that should be something you can do with a little thought.
Regards
Message was edited by:
blushadow

Similar Messages

  • How to make a snapshot out of a movie file?

    How to make a snapshot out of a movie file and integrate this snapshot into the movie? Thanks, Wolfgang

    Either you use the Hold function from the Retiming popup or you export an image and reimport it.

  • How to make a function return number(10,0) data type (ORACLE 10g)?

    With 10g, how to make a function return number(10,0) data type?
    here is the function, it returns a number type :
    create or replace FUNCTION Get_portfolio_Id3 (p_HistObjTable In Varchar2,p_LHISTOBJID IN NUMBER) RETURN view_cpu_STD_Asset.LPORTFOLIOITEMID%Type IS
    v_Id view_cpu_STD_Asset.LPORTFOLIOITEMID%Type;
    BEGIN
    If p_HistObjTable ='amPortfolio'
    then v_Id:=p_LHISTOBJID ;
    elsIf p_HistObjTable = 'amComputer' then
    select litemid into v_Id from smcdba.amComputer c where c.LCOMPUTERID=p_LHISTOBJID ;
    else v_Id:=-99;
    End If;
    RETURN v_Id;
    END Get_portfolio_Id3;
    Thanks.
    Message was edited by:
    user631701

    create or replace FUNCTION Get_portfolio_Id3 (p_HistObjTable In Varchar2,p_LHISTOBJID IN NUMBER) RETURN view_cpu_STD_Asset.LPORTFOLIOITEMID%Type IS
    v_Id view_cpu_STD_Asset.LPORTFOLIOITEMID%Type;
    BEGIN
    If p_HistObjTable ='amPortfolio'
    then v_Id:=p_LHISTOBJID ;
    elsIf p_HistObjTable = 'amComputer' then
    select litemid into v_Id from smcdba.amComputer c where c.LCOMPUTERID=p_LHISTOBJID ;
    else v_Id:=-99;
    End If;
    RETURN round(v_Id);
    END Get_portfolio_Id3;

  • How to make a key out of this data?

    Since no one replied to my last post, I'll give it another try. From an RTSP server I get two values, a key called rsaaeskey (342 bytes, without the line breaks):
      yxKBocBgTii20n9nbKfYGyGhPqtosXuq8M99yU5/PzTVNmIUsUGlpD27u
      cqN8eNFvmaO7cFVXeaMGaCfI5V+YNrd77xGQ+CUE0XFraXUvp4cF4aX1L
      ZOGe38nwX3Ba+4bQFfjmYgz3ObRuOWlw9KCi4CMP5574F+CIvutVAwtAC
      PiDFF7nVcoaBTr2QbSUile0Zs3Hyxjn9PWVaey9Nu2DgJZ8rtw6F2SkQ7
      NDHBjjUKXNIeCAeBFuV4XNiazvi3gWa4VbgITtD9jcm+7nPMAK0oBL1S3
      K3Z6FK7XVnfehYYJjRw7THMZzSvq7FtLB9QgulqQTJ3awJdwS0ACb1FkAand an initialization vector called aesiv (22 bytes):
      zcZmAZtqh7uGcEwPXk0QeAThe data is obviously Base64 encoded. However, after decoding I don't know how to make a key out of it. Trying KeyFactory's generatePublic and generatePrivate methods result in an InvalidKeySpecException with any algorithm I've tried (RSA, DSA, DH).
    I think this is a multi-prime RAS secret key (someone said they're 342 bytes long), but how do I generate a Java Key out of it?

    The rsaaeskey, decoded to binary, is a binary array of 256 bytes. Using the DUMPASN1 tool we see that the bytes are not in ASN.1 BER or DER encoding.
    C> openssl enc -base64 -d -in rsaaeskey.base64 -out test.bin
    C> dumpasn1 rsaaeskey.bin
       0 CB   18: [PRIVATE 11]
                :   81 A1 C0 60 4E 28 B6 D2 7F 67 6C A7 D8 1B 21 A1
                :   3E ABIf it were encoded in ASN.1 BER or DER encoding it will start as a "SEQUENCE" or a "SET", not as an unrecognized data.
    You need to check the exact specification of the protocol. (Are you using TSP - RFC 3161, or RTSP - RFC 2326?)

  • How to make a stationery out of .doc or .docx file?

    Hi,
    I stumbled upon a website that has some nice stationery, in .doc format. and since there few free pre made stationery available for Mail.app, at least to my knowledge, because I think I almost downloaded every free stationery available out there that could be easily found via Google. I decided to download some of these .doc stationeries and try to put them in Mail.app, but first I had to convert them into .html format. so here is what I've already tried and did not work:
    first I tried opening them in TextEdit, which supports .doc out of the box, only to find out that the pictures in the documents are gone to thin air. I tried saving it and then opening it with something else like Open Office, but the pictures were permanently gone.
    then I tried opening the original documents directly in Open Office, you guessed right If you said they will look screwed, and they were, and tried to save them as html, they were screwed even more.
    so I did a bit of research and found out that I could use Google Docs in order to convert the documents, I uploaded them into my Google docs and then tried to open them with it, but found it that Google docs can't handle the pictures (specially background pictures) either. as a result I did more searching to find a document converter and here is what I found:
    I found a few online service to convert these documents:
    http://www.freefileconvert.com/ was pretty good to convert the files into an .odt format. at first I thought yes I got the solution, now I can simply convert it to html using Open Office, but unfortunately, when I saved the document in html format and checked it in Safari to see how does it look, as If I would have done the same in MS Office with the original format, it looked pretty much screwed .
    So I continued to look and I found a few other online services one of them asked me to pay a fee, I skipped to the other one which was http://docx-converter.com/. unfortunately the website wasn't functioning properly I think, at least for me (maybe someone out there has succeeded using it, I don't know.) and it didn't send me anything.
    Finally I found http://www.zamzar.com/ that could convert .doc or .docx documents into html, or at least that is what it claims to do so, I tried it, and after I received the file via email, I found out it only contains a bmp image of the document's background. So much for the online conversion services!
    But I decided I would give it a last shot using MS Office online, so I opened up my old Windows Live mail and went into my Skydrive, I uploaded the documents and tried saving it as html, but there were no save as html (after all an online copy of MS Office should have some limitations, otherwise few people will be willing to buy a Desktop version) but this didn't made me disappointed, since I already knew, that Neither Office Word can make a clear conversion, so I tried something different, while I was in Safari looking at the document in online MS office, I saved the page as Web Archives, then I opened the file with TextEdit, and after deleting useless links and pictures, I finally managed to get a clear document with everything that supposed to be in it. At this point I only need to know how to make use of this document to create a stationery with this raw file which is in Web Archive format. any ideas?
    null

    I'm a total idiot! How did I overlook http://www.zamzar.com/ functions? I think I might have mistakenly chosen convert to BMP instead of html. I tried it and the result was very good.
    OK I finally found a good solution for this problem, so everyone out there that has the same problem, here is what I did:
    1. OK if you have some .doc and .docx file formats and you want to convert them into something like .html or .odt, without having to reedit the code or getting a screwed document, use http://www.freefileconvert.com/ in order to convert them into .odt so they would look as they do in MS office just go to the website and upload your documents then choose .odt, then click convert, after a few moments you will get a link to download your .odt files. you can use and play around with your document in Open Office, I have tested it and it's really good.
    2. Or if you want to convert them into .html with a clean code, and all the elements in it, simply go to http://www.zamzar.com/ and then ulpoad your documents, choose .html and enter your email address, you will have your .html files zipped and sent right in your inbox, then you could use Kompozer like me, or any other html editor, to make a template out of it. I tried it and the result was nice, now I have a bunch of nice html files that I can use to make templates and email stationery.

  • How to make a function take a specific group of constants

    I know i asked this before, maybe a year ago, but I totally forgot how to do it, and I haven't been programming much lately. But I was wondering if somebody can tell me how to make a certain function take specific constants. For example there are java functions, of which I can not remember that will only take certain values. So the function might look like:
    public getInfo(String INFONAME){}Where INFONAME has to be like one of two names or something, and they are constants that are defined somewhere else. If anybody knows what I mean by this, and knows how to create functions like that please let me know. Thank you.

    here's an overkill,
    import java.util.*;
    abstract class DoWhatever {
        public static Hashtable ht = null;
        public static Object DoWhat( String s, Object obj ) {
         if( null == ht ) {
             ht = new Hashtable();
             ht.put( ThisDoWhatever.NAME, new ThisDoWhatever() );
             ht.put( ThatDoWhatever.NAME, new ThatDoWhatever() );        
         return ( (DoWhatever) ht.get( s ) ).doWhatever( obj );
        public abstract Object doWhatever( Object obj );
    class ThisDoWhatever extends DoWhatever {
        public final static String NAME = "this";
        public Object doWhatever( Object obj ) {
         System.out.println( NAME );
         return null;
    class ThatDoWhatever extends DoWhatever {
        public final static String NAME = "that";
        public Object doWhatever( Object obj ) {
         System.out.println( NAME );
         return null;
    public class DoThisOrThat {
        public static void main( String[] args ) {
         DoWhatever.DoWhat( args[ 0 ], null );
    }

  • PL/SQL: How to make a function accessible to all users?

    How can I make a function accessible to all users?
    I have written a stored function called GET_NET_BALANCE.
    I can run it but my users cannot.
    I have tried the following, but my users still cannot
    run the function:
    GRANT EXECUTE ON GET_NET_BALANCE TO PUBLIC;
    Thanks, Eileen

    Hi,
    You can try creating a public synonym on the function so that it is accessible to all.
    To get greater response.. please post your question at
    PL/SQL
    Regards,
    Anupama

  • Mailing list form, how to make it functional?

    I'm trying to add the typical "Join our Mailing List" form into a website where users can submit their email addresses.  I've built the form and now I need to make it functional.  I don't know a lick of php or databasing, and after investigating it on the web and the forum there seems to be a bunch of different answers and I'm not sure which direction to go in.  Is there an easy way to do this with a premade script somewhere?  Would I have to get it from the company that's hosting the site?  How do I implement it?
    Thanks in advance!!!!

    Awesome, thanks so much for the help CanonBoy.  So I can use this for both my mailing list form and my contact message form?  I opened Dreamweaver and on the contact page I set the form to this:
    <div id="ContactForm">
      <form id="form1" name="form1" method="post" action="contact.php">
        <table width="300">
          <tr>
            <td colspan="2"><span class="MainText">All information will be kept private</span></td>
          </tr>
          <tr>
            <td width="61"><span class="MainText">Name:</span></td>
            <td width="227"><span class="MainText">
              <input name="Name" type="text" id="Name" size="25" />
            </span></td>
          </tr>
          <tr>
            <td><span class="MainText">Email:</span></td>
            <td><span class="MainText">
              <input name="Email" type="text" id="Email" size="25" />
            </span></td>
          </tr>
          <tr>
            <td><span class="MainText">Phone:</span></td>
            <td><span class="MainText">
              <input name="Phone" type="text" id="Phone" size="25" />
            </span></td>
          </tr>
          <tr>
            <td> </td>
            <td> </td>
          </tr>
          <tr>
            <td><span class="MainText">Message:</span></td>
            <td><span class="MainText">
              <textarea name="Message" id="Message" cols="23" rows="5"></textarea>
            </span></td>
          </tr>
          <tr>
            <td> </td>
            <td> </td>
          </tr>
          <tr>
            <td> </td>
            <td><input name="Clear" type="reset" class="MainText" id="Clear" value="Clear" />
            <input name="Submit" type="submit" class="MainText" id="Submit" value="Submit" /></td>
          </tr>
        </table>
      </form>
    </div>
    Do I have to change the form ID and the name in line 2?  And also I'm not sure what you meant about the hidden field, what exactly do I copy and paste and where do I put it?  And is there a generic form on the tectite site I can add the client's email address to, change it to contact.php and upload it?  Thanks big time!!!

  • Video Answer to "How to make 3D Video out of regular 2D Video"

    Didn't know how to do that and asked here this question 2 month ago - Is it possible to make 3D video out of regular 2D video file to watch further on my iPod. So I came across an answer to this on ...Youtube!
    Here are two video screencasts I found to progs that can do such thing, So I've tried and now enjoy my movies in 3D on iPod.
    If you're interested then deffo check them out:
    http://www.youtube.com/watch?v=lUYT-c5leSU
    http://www.youtube.com/watch?v=_TxRMGUwGS0

    follow advice given in this User Tip
                     How can I make a still frame from iMovie 11? (also works in iMovie 10)

  • How to make a gif out of a movie clip?

    So yeah... I'm an idiot when it comes to these things.
    How do I go about doing a gif of a small video?
    And... Could you do the explanation in a step by step guide please. Thanks

    Video to GIF | free Video to GIF Generator on Make A GIF
    Animated GIF Generator - Imgflip
    How to Make an Animated GIF from a Video in Photoshop CS5
    The Complete Guide to Making Animated GIFs - Lifehacker
    Giflike - Create a gif from YouTube, video or images
    GIF Maker From Videos. Create Awesome Gif Animations ...
    Bloggif : Convert video to animated GIF for free

  • How to make a "Program" out of my .java files?

    I have made a little application that stores a file to disk. Is there someway to make a file out of my .java files so it can be run without opening my editor and choosing run?

    sorry I didn't check that, I can now run the jar command.
    But even though I can create a .jar file I get an error. I have followed the guide that says I need to add the applications Entry point.
    I have two classes:
    saveDates.class //contains the main method
    UserInput.claa // Parsing of user input
    When I create the jar file I type:
    jar cfe saveDates.jar SaveDates SaveDates.class UserInput.class
    But when I try to run it like:
    java -jar saveDates.jar
    I get the error:
    C:\workspace\dato>java -jar saveDates.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: SaveDates$1
    at SaveDates.main(SaveDates.java:89)
    C:\workspace\dato>
    Do I need to change the main method someway?

  • How to make a fly-out menu item checked?

    Hi,
    is there a way to make a fly-out menu item (coming from an XML list) checked - like in this example:
    by the way, I know it's been submitted as a bug already, but fyi sub-menu items (2-1 in the following example) don't work as expected:
    var xmlMenu:XML =
        <Menu>
          <MenuItem Id="item_1" Label="Item 1"/>
          <MenuItem Label="Item 2">
            <MenuItem Label="Item 2-1"/>
          <MenuItem/>
          <MenuItem Label="---"/>
          <MenuItem Label="Item 3"/>
         </Menu>;
    Thanks in advance!
    Davide

    If Harbs says nope, it's nope
    At least now I know it. Thanks!
    Davide

  • How to make a function in separate thread

    i need to make a function that is running in a separate thread
    Thank's in advance

    Thank's
    but in my program i have a main class which is a server it runs forever.
    from the main class when i call a function it runs in a separate thread and returns the result to the callee and the main function continue it's work
    class server
    //this function when called must be in separate thread
    public int function(int x)
    //there could be wait here or sleep
    return x*2;
    public static void main(String[] args)
    // Run RMI server
    i hope u understand me!!!
    Thank's

  • How to use MAX function in SSAS MDX Query

    I want to run this Query with MAX Condition on LAST_DATA_UPDATE Column .

    Hi Ashishsingh,
    According to your description, you want to know how to use MAX function in SQL Server Analysis Services MDX Query, right? In this case, please refer to the link below which describe the syntax and sample of MDX function.
    http://technet.microsoft.com/en-us/library/ms145601.aspx
    http://www.mdxpert.com/Functions/MDXFunction.aspx?f=64
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to make a Lay-Out

    Hello!
    I am using pages for a few months now, but there is one thing I can't get. If you make a project many people with the newest word have a beautiful lay out. For example with colored lines on each page. I was wondering. How can I get something like that in pages? I have looked at the templates but they don't have them and if I open a template I only see the first 2 pages of the whole template.
    Best regards,
    Cathelijne

    MZ,
    There's no magic in those templates that you buy. You're just paying for the designer's time and talent to do what any similarly talented person could do with Pages, given the time.
    What most users would lack, in addition to the training and experience and "the eye" to produce such nice layouts, is the other graphic software that may have been used to facilitate the creation of the background images/graphics that may also be there. Pages has drawing tools, but they would be inadequate, I would guess, to satisfy a graphic designer doing production work. You might be surprised, though, at what can be achieved with the built-in tools if you have the patience.
    Jerry

Maybe you are looking for

  • Fieds are not appearing in rss3

    HI experts, we have added 2 fields ( one char nd one kf). activated ds , structure everythng. Filled setup tables. Aftr that i cant see them in rsa3. Chekd in lay out also . What is the reason???? awaiting your reply. br, RAvi

  • SmartForms and ABAP Objects

    Hi all, I'm trying to use ABAP Objects with smartforms. The thing is that whenever I need to display an object attribute, I have to call a getter method (say object->getSomeAttribute for example), assign the return to a global variable in the smartfo

  • My text tone is really quite even though it's put on the highest volume.

    I just updated my iPhone 4S to the iOS 6. However, my text tone is really quite although it's put to the highest volume. The ringtone is loud but the text tone is really quite including the "Swish" sound when you send a text. It's really annoying me.

  • Upgrade to SQL2008 to SQL2008 R2 on 32 bit 2008 server

    Hi There  We have 2008 32 bit server  running with SQL2008 & now we want to upgrade the it to SQL2008 R2.  Is it possible to upgrade or install the  SQL2008 R2 on 32 bit server. Regards Rahul

  • Passsword reset

    HI When I am Login in the OBIEE adminstartion window and opening the online mode it was asking the adminisatrtor password I have given password but I am getting below error : nQSError:37001 could not able connect to oracle BI server nQSError :43001 A