Get first_day and last_day in oracle

create or replace FUNCTION system.f_day(value_in DATE)
RETURN DATE IS
vMo VARCHAR2(2);
vYr VARCHAR2(4);
BEGIN
vMo := TO_CHAR(value_in, 'MM');
vYr := TO_CHAR(value_in, 'YYYY');
RETURN TO_DATE(vMo || '-01-' || vYr, 'MM-DD-YYYY');
EXCEPTION
WHEN OTHERS THEN
RETURN TO_DATE('01-01-1900', 'MM-DD-YYYY');
END f_day;
CREATE OR REPLACE PUBLIC SYNONYM first_day FOR system.f_day;
select first_day(trunc(sysdate,'MM')-1),last_day(trunc(sysdate,'MM')-1)
from dual;

Wason Naveen wrote:
My problem is solved.Unfortunately the problems are just beginning for whoever uses that code.
It should simply be
SQL> select trunc(sysdate,'MM'), trunc(last_day(sysdate)) from dual;
TRUNC(SYS TRUNC(LAS
01-MAR-10 31-MAR-10 No function required.

Similar Messages

  • How to get username and password for oracle database

    i downloaded oracle database on the assumption it is free software. however when i go to the oracle homepage it says i need a user name and password. how do i get one? is it free

    >
    i downloaded oracle database ...Which version???
    >
    .. is it free...XE 10 is free all other are not
    Edited by: Damir Vadas on Nov 17, 2009 3:34 PM

  • Problem with getting current date and time using oracle.jbo.domain.Date

    I`d like to get current date and time using oracle.jbo.domain.Date method getCurrentDate(), but it always return current date and 12:00:00. I also need to get the current time.

    I think you should use java.sql.Timestamp domain.
    (And set database type to TIME or DATETIME.)
    Jan

  • How can I get the username and password from Oracle Forms to PJC !

    Dear Sir,
    I have username,password and push button fields in oracle forms. When user clicks the push button, I need to get username and password field contents to my Pluggable Java Program to authenticate the user trying to login. How can I get those text field contents to my java program..? Looking forward from you soon sir.
    Thanks in Advance,
    S Ramkumar

    I tried that trigger but nothing reflects. I write that method in WHEN_BUTTON_PRESSED trigger.
    In the form module I written,
    Set_Custom_Property('BL.USERNAME',1,'NAME','');
    Set_Custom_Property('BL.PASSWORD',1,'PASS','');
    Implementation class of the push button I gave my java class file name.
    In Java Code I tried register the form fields like,
    public static final ID userName = ID.registerProperty("NAME");
    public static final ID passWord = ID.registerProperty("PASS");
    In Java Code I tried get the contents from registered properties,
    public boolean setProperty(ID property, Object value) {
    if(property == userName) {
    System.out.println("Just I wish to see the name entered" + value.toString());
    if(property == passWord) {
    System.out.println("Just I wish to see the pass entered" + value.toString());
    But even System.out.println() is working.
    What's wrong with this code sir ???
    Can you tell me How to register and get those field values in Java ?

  • How to get email and sms alerts in 9i

    Hi,
    I want to know that is there any method in 9i by which we may get mail and sms alerts whenever anything goes wrong with the database?
    Thanx

    Why pay for something if you already have it, included in your license?
    Only because you have to read documentation to use it?
    Oracle will sooner or later include functionality in their monitoring products, they don't include in the RDBMS. In 10g you already rather use the controls than call the PL/SQL Apis directly.
    Apart from that: the third party products you seem to promote, usually implement very limited functionality.
    Sybrand Bakker
    Senior Oracle DBA

  • Unable to get Windows User Name using Oracle Forms 6i, Jinitiator 1.3.1.17

    Hi,
    Requirement: Get Windows User Name using Oracle Web Forms 6i.
    Tools Using: Windows NT, Oracle web forms 6i, Oracle 10g DB.
    Description: I am using GetClientInfo JBean from otn.oracle.com, which gets windows user name, IP address and machine name. The demo I got from oracle web site uses Jinitiator version 1.1.7.18. While we are using the latest version Jinitiator 1.3.1.17. Due to this reason, I am unable to use Javakey which comes with older version but doesn't come with newer version, that's why I can't create the new JavaBean Java identity (PJC).
    Please advise what to do. All environment variables are set everything is done, this is the only thing bothering me.
    I went through the article 202768.1 from metalink, but on step 5, it gives an error keytool error: java.lang.Exception: Input not an X.509 Certificate.
    Also, please let me know if there is any other workaround for this requirement.
    Thanks & Best Regards,
    Mo

    Hi,
    Thanks for your kind reply. Actually there was a problem in creating a certificate, now it is okay with the same method. Certificate got imported on client and everything is ready.
    Now, the problem is when I try to set Bean Area Implementation Class property with oracle.forms.demos.GetClientInfo, it gives an error FRM-13008 Cannot find JavaBean with name 'oracle.forms.demos.GetClientInfo'.
    I went through the articles 1072329.6, 196824.1, and set ClassPath and Path variables with proper values. Also, I have copied jar file and signature file in forms60/java folder. I don't see any problems. Please let me know what I am doing wrong. My limitation is that I have to do all this in forms6i.
    I searched forums on metalink and found out that someone installed Patch 15, and everything went okay for him. Do you think I should install Patch 15? if YES, how will I do it, I mean should I first uninstall my forms and then install patch15 or install the patch on my forms?
    Thanks so much for your help.
    Thanks & Best Regards,
    Mo

  • How to get the file name from Oracle B2B 10g

    Hi My requirement is I am getting a CSV file from Trading partner, I am using oracle 10g b2b to translate the data.
    In my BPEL 10g I am using AQ adapter to get the message from IP_IN_QUEUE.
    Now I want to get the file name Eg: SampleFile.dat of the CSV file in my BPEL process.
    I tried using the b2b.filename property in the receive activity and it is not getting the file name.
    <sequence name="main">
        <receive name="Receive_Note" partnerLink="GetB2BNote"
                 portType="ns1:Dequeue_ptt" operation="Dequeue"
                 variable="Receive_Note_Dequeue_InputVariable"
                 createInstance="yes">
                 <bpelx:property name="b2b.fileName" variable="WriteFileName"/>
        </receive>
      </sequence>
    Can you help me to get the file name from Oracle b2b 10g ?
    Thanks,
    b2b user

    Hi My requirement is I am getting a CSV file from Trading partner, I am using oracle 10g b2b to translate the data.
    In my BPEL 10g I am using AQ adapter to get the message from IP_IN_QUEUE.
    Now I want to get the file name Eg: SampleFile.dat of the CSV file in my BPEL process.
    I tried using the b2b.filename property in the receive activity and it is not getting the file name.
    <sequence name="main">
        <receive name="Receive_Note" partnerLink="GetB2BNote"
                 portType="ns1:Dequeue_ptt" operation="Dequeue"
                 variable="Receive_Note_Dequeue_InputVariable"
                 createInstance="yes">
                 <bpelx:property name="b2b.fileName" variable="WriteFileName"/>
        </receive>
      </sequence>
    Can you help me to get the file name from Oracle b2b 10g ?
    Thanks,
    b2b user

  • How to get the papi wsdl of Oracle BPM Studio

    How to get the papi wsdl of Oracle BPM Studio. What is the url of the papi wsdl of Oracle BPM Studio

    Thanks to Lovin:
    There is an icon in the studio when the engine starts.. called as "Launch Deployed Webservice webapp"
    Also.. Need to go to Engine Preferences -> Engine -> Advanced Tab -> Startup and select Start PAPI Web Services.
    Default URL:http://localhost:8585/papiws/PapiWebServiceEndpoint?wsdl

  • Oraarch file getting generated very often in /oracle/ SID /oraarch/

    Dear All
    I am facing a problem of getting oracle archive (oraarch) generated very frequently nearly 50MB file in less than a minute due to which my Filesystem capacity of Oraarch is getting full soon.
    I have monitored there is no any batch job, Upload job, or any loaded job going even in Idle time in late night the same frequency of Archival is going so in a duration of 6-7 hours i am getting the total archive of 50GB.
    I have Oracle 10g Patch Set 10.2.0.4.0 and all the 39 Patches & 2 CPU Patches applied by Opatch & MOPatch and all the Oracle 10g Parameter  are set as per the note 830576.
    Can you please let me know what can be the issue?
    Thanks & Best Regards
    Rahul

    You probably have statistics being populated and AWR running. Oracle 10g has system jobs that are set to run frequently (i.e. every hour, every night, etc).
    column repeat_interval format a70
    select job_name, repeat_interval, enabled from dba_scheduler_jobs;
    column what format a50 word_wrapped
    select job, last_date, next_date, broken, what from dba_jobs;
    50mb is probably too small for your environment. You'll probably want to at least double that... at least.
    And if your oraarch is filling up so frequently you should consider increasing the space of oraarch. It sounds like your system is much busier than you expected.
    Run this command to get an idea of what Oracle recommends for your redo log file sizes...
    SELECT TARGET_MTTR,ESTIMATED_MTTR,WRITES_MTTR,WRITES_LOGFILE_SIZE, OPTIMAL_LOGFILE_SIZE FROM V$INSTANCE_RECOVERY;
    If that doesn't work it's probably because you're not using the system parameter fast_start_mttr_target... which I guess is something SAP advises against using?  I'm an Oracle DBA but a SAP newbie so I'm still learning what parameters SAP wants me to set and why
    Hope that helps..
    Rich

  • File Upload and Download in Oracle iAS PL/SQL Gateway

    i'm using the example 113471.1 to "File Upload and Download in
    Oracle iAS PL/SQL Gateway"
    when i press the submit button after i select a file to upload
    i get the next message in the browser "No se puede mostrar la
    pagina" HTTP 404 file not found.
    I think the problem is in ctnsample.upload_form in the line
    htp.formOpen(curl => 'cntsample.upload', cmethod => 'POST',
    cenctype => 'multipart/form-data');
    The ctnsample.remove work fine.
    Could you,help me...

    There is a document in the Oracle 9iAS 1.0.2.2 Library titled "Using the PL-SQL Gateway" Part Number A90099-01.pdf that explains file upload and download through modplsql. In particular there is a section there titled "Direct BLOB Download" which explains how one can easily download a blob utilising the wpg_docload package.
    I am still concerned that there exist duplicate copies of my blob content. One copy in the wwdoc_document$ table, and one in my custom table.
    Dmitry/Oracle can you confirm this?

  • Getting exception whil calling an oracle stored procedure from java program

    Dear All,
    I encounter this error in my application when I call only the stored procedure but the view is executing fine from the application and my environment is as follow:
    Java 1.4
    oracle 10g
    oracle jdbc driver:9.2.0.8.0
    websphere portal 6.0.0.1
    this error is occur from time to time randomly, when it happens, the only workaround is to restart the server..Does anyone have any idea about this error?
    Unable to execute stored Procedure in Method
    java.lang.NullPointerException
    at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java(Compiled Code))
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1140)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java(Compiled Code))
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java(Compiled Code))
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3606)
    at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5267)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecute(WSJdbcPreparedStatement.java:632)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.execute(WSJdbcPreparedStatement.java:427)
    And sometime I am getting this exception
    Unable to execute stored Procedure in Method
    java.lang.ArrayIndexOutOfBoundsException: 27787320
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java(Compiled Code))
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1134)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java(Compiled Code))
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java(Compiled Code))
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3606)
    at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5267)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecute(WSJdbcPreparedStatement.java:632)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.execute(WSJdbcPreparedStatement.java:427)
    Thanks
    Jay

    spacetorrent escribi&oacute;:
    for (int x=0; x <result.size(); x++){
    System.out.println(result.get(x));
    I can't do this, because result object is a Map, and I need write the Key of the Value to obtain.
    So I can do:
    result.get("res");And I odtain a *$Proxy3* Object

  • Mean,Median and Mode in Oracle 9i

    Hello Users,
    Is there any analytical functions for MEAN,MEDIAN and MODE in Oracle 9.7.2 ? In Oracle 10g I could see these functions.
    Appreciate your help.
    Regards,
    Ravi

    Hi Ravi,
    user13153556 wrote:
    Hello Users,
    Is there any analytical functions for MEAN,MEDIAN and MODE in Oracle 9.7.2 ? Do you mean Oracle 9.<b>2</b>?
    All built-in functions are listed in the SQL Language manual:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/index.htm
    In Oracle 10g I could see these functions.You can use PERCENTILE_CONT or PERCENTILE_DISC to get the median in Oracle 9. You can also use ROW_NUMBER.
    I don't see MEAN or MODE even in Oracle 10.
    Use AVG for mean.
    ROW_NUMBER is one way to find the mode.

  • Geting and setting date and time in oracle using jdbc

    can u send me a sample snippet which shows me how to set date and time to a column in oracle database where the column datatype is date.
    and also send me the sample code to get the date and time from the above said column
    thanks in advance

    If you want DATE with time normalized to midnight, use java.sql.Date. If you really want time, with hours/minutes/seconds/millis, use java.sql.Timestamp.
    As for the best way to interact with the database, use java.sql.PreparedStatement and its get/setDate and get/setTimestamp methods. Those will escape dates for you properly.
    Look for a JDBC tutorial on-line to see how to do this, or http://www.javaalmanac.com for the java.sql package examples.
    %

  • Archive and Purge in Oracle Financials (verions 11.0.3, database 8.0.5)

    Hi all,
    I am going to purge balances and journals data by using function 'Archive and Purge' in Oracle Financials.
    I want to calculate the space that can free up finally.
    i.e. calculate the difference before and after data purging.
    How to get this information?
    Thanks for your kind response.

    Assuming you have the source data in access97.
    Create tables in Oracle exactly the same as access tables.
    Create links from access ODBC drivers to Oracle tables.
    Export the data from access.
    If you want to keep the sources data in access and update the data everyday, you can use append queries.
    YOu can refresh the data by truncating the destination tables and export fresh.
    Another option is sql*loader. It depends what your situation is.
    null

  • Floats/Numbers, and Changes between Oracle 8,9,10 and 11

    Hi
    I'm trying to get our application to support Oracle 11, it works fine with Oracle 10 and before. I wonder if someone can help me with this.
    Suppose you have an SQL statement with a constant like this:
    select my_agent_id, 0 team_id
    from my_agent
    Note: The second column is a constant (0).
    In Oracle 8, 9, 10, when this statement is described, Oracle says that the team_id column is an integer type (number). But in Oracle 11, it reports it as a floating-point type.
    This causes errors: our datasets are expecting interger types, but Oracle now says these are floats.
    Can anyone help? Please don't say 'take the constant out' because that's quite hard, as we have datasets that are in some cases used with different sql statements. Oracle upgrades are usually easy because Oracle are pretty good at version compatibility.
    Here is some additional info.
    Our app is an OCI app written using MSVC. The code that says the team_id is a float is here (I have removed error checking code):
                   luiResult = OCIAttrGet(     (ORAVOID *)lpssParam,
                                                 OCI_DTYPE_PARAM,
                                                 (ORAVOID *)&cSc,
                                                 0,
                                                 OCI_ATTR_SCALE,
                                                 (OCIError *)opuoTrans->opssError);
                   if (luiResult != OCI_SUCCESS) {     
                        return BINDOUTPUT_GET_PREC;
                   if (cSc == 0) {
                        *aiType = DBPROV_INT; // Oracle 8,9,10 goes here
                   } else {
                        *aiType = DBPROV_FLOAT; // Oracle 11 returns -127 so here
    The value of cSc is -127, the code for FLOAT as written in the manual.
    Anyway, this seemingly small thing is enough to make the application go bang.
    Any help appreciated.

    I believe what you're seeing here is expected behavior. Oracle 9.2.0.3 and later fixed the old behavior. Your code should be looking for a non-zero precision and a scale of -127 to determine that the column is a float.
    Metalink 255902.1 Number Datatype Returns -127 instead of 0 for Unspecified Scale seems to be directly on point here.
    Justin

Maybe you are looking for

  • Address Book/Sync Destroying Contact Info

    Address Book crashed on me yesterday and destroyed/deleted about 600 records (of ~650). It replaced the data file with something very old (more 2+ years old). It then synched with my Entourage data base deleting all the same contacts without warning.

  • Why won't my Mac Pro go to sleep any more?

    I upgraded to yosemite I a few days later I noticed that my mac pro (3.1 early 2008 dual 2.8 xeon processors, two sad's one hdd, 14GB memory) doesn't go to sleep any more.  When I choose sleep from the Apple menu the displays go dark and it looks lik

  • Apps doesn't show up in iTunes after Sync

    I synced my iPhone to a new Macbook, as my old PC had crashed, and the Apps in my iPhone doesn't show up in the iTunes. what should i do?

  • My iphone is causing tingling in fingers and up arm

    Hi, all.  When I use my iPhone 4 I am getting electrical shocks that begin in my fingers and go up my arm...depending on how long I use the phone.  I tried it with the adapter plugged in and without the adapter.  It does it both ways.  It does it whe

  • I have iphone6 and I cant open PDF files which attached to my email

    Dear All I have iPhone and I cant open PDF files which attached to my email Regards