Sysdate

Hi,
how much is detailed sysdate?
Does it contain more than seconds?
I'm using 8.1.7.4
I created a primary key and one of the columns is of date value.
Against this table i issue many inserts sequentially with sysdate for the date column and sometimes the insert fails because the unique constraint is violated.
So i have to change the PK if the sysdate is not so much detailed. Any tips?
Tarek

SQL> create table pippo (a varchar2(4), b date,
2 constraint pk_pippo primary key(a,b));
Table created.
SQL> desc pippo
Name Null? Type
A NOT NULL VARCHAR2(4)
B NOT NULL DATE
SQL> insert into pippo values('aaaa',sysdate);
1 row created.
SQL> /
1 row created.
SQL> /
insert into pippo values('aaaa',sysdate)
ERROR at line 1:
ORA-00001: unique constraint (PIPPO.PK_PIPPO) violated
SQL> /
1 row created.
SQL> /
1 row created.
SQL> //
insert into pippo values('aaaa',sysdate)
ERROR at line 1:
ORA-00001: unique constraint (GHADDART.PK_PIPPO) violated
SQL> /
1 row created.
SQL> /
insert into pippo values('aaaa',sysdate)
ERROR at line 1:
ORA-00001: unique constraint (GHADDART.PK_PIPPO) violated
SQL> /
1 row created.
SQL> /
1 row created.
SQL> /
1 row created.
SQL> /
1 row created.
SQL> /
insert into pippo values('aaaa',sysdate)
ERROR at line 1:
ORA-00001: unique constraint (GHADDART.PK_PIPPO) violated
SQL> /
1 row created.
SQL> select a, to_char(b,'DD-MM-YYYY HH24:MI:SS') from pippo;
A TO_CHAR(B,'DD-MM-YY
aaaa 02-10-2003 09:33:40
aaaa 02-10-2003 09:33:41
aaaa 02-10-2003 09:33:42
aaaa 02-10-2003 09:33:43
aaaa 02-10-2003 09:33:44
aaaa 02-10-2003 09:33:45
aaaa 02-10-2003 09:33:49
aaaa 02-10-2003 09:33:51
aaaa 02-10-2003 09:33:52
aaaa 02-10-2003 09:33:53
10 rows selected.
Ok.. the problem is that the precision is seconds.
Thanks for all your replies.

Similar Messages

  • Query help : Query to get values SYSDATE-1 18:00 hrs to SYSDATE 08:00 hrs

    Hi Team
    I want the SQl query to get the data for the following comparison : -
    Order Created is a Date Column , and i want to find out all the values from (SYSDATE-1) 18:00 hours to SYSDATE 08:00 hours
    i.e.
    (SYSDATE-1) 18:00:00 < Order.Created < SYSDATE 08:00:00.
    Regards

    Hi, Rohit,
    942281 wrote:
    If i want the data in the below way i.e.
    from (SYSDATE-1) 18:00 hours to SYSDATE 17:59 hours ---> (SYSDATE-1) 18:00:00 < Order.Created < SYSDATE 07:59:00.If you want to include rows from exactly 18:00:00 yesterday (but no earlier), and exclude rows from exatly 08:00:00 today (or later), then use:
    WHERE   ord_dtl.submit_dt  >= TRUNC (SYSDATE) - (6 / 24)
    AND     ord_dtl.submit_dt  <  TRUNC (SYSDATE) + (8 / 24)
    So can i use the below format : -
    ord_dtl.submit_dt BETWEEN trunc(sysdate)-(6/24) and trunc(sysdate)+(7.59/24) . Please suggest . .59 hours is .59 * 60 * 60 = 2124 seconds (or .59 * 60 = 35.4 minutes), so the last time included in the range above is 07:35:24, not 07:59:59.
    If you really, really want to use BETWEEN (which includes both end points), then you could do it with date arithmentic:
    WHERE   ord_dtl.submit_dt  BETWEEN  TRUNC (SYSDATE) - (6 / 24)
                      AND         TRUNC (SYSDATE) + (8 / 24)
                                               - (1 / (24 * 60 * 60))but it would be simpler and less error prone to use INTERVALs, as Karthick suggested earlier:
    WHERE   ord_dtl.submit_dt  BETWEEN  TRUNC (SYSDATE) - INTERVAL '6' HOUR
                      AND         TRUNC (SYSDATE) + INTERVAL '8' HOUR
                                               - INTERVAL '1' SECONDEdited by: Frank Kulash on Apr 17, 2013 9:36 AM
    Edited by: Frank Kulash on Apr 17, 2013 11:56 AM
    Changed "- (8 /24)" to "+ (8 /24)" in first code fragment (after Blushadown, below)

  • How to insert the sysdate time into the database

    hi all,
    when i execute the following query,
    insert into table_name
    (date_field)
    values
    (to_date(sysdate, 'yyyy/mm/dd hh24:mi:ss'));
    The value is inserted as 08-02-12 12:00:00. In this query, it always stores the default time as 12 a.m.
    But i need to insert the original system time not the default one.
    please help me how to rectify it.

    I do not understand as to why you are using the to_date function on sysdate since sysdate is already in date format.
    If date_field is of the data type date, then the following dml should work.
    insert into table_name(date_field) values (sysdate);
    In case date_field is a varchar2 field and you want to store the date and time in a string format, then the following statement should work.
    insert into table_name (date_field)
    values (to_char(sysdate, 'yyyy/mm/dd hh24:mi:ss'));

  • Difference between sy-datm and sysdate in a variant of a report

    hi,
    I am working on a report which fills the database and i had assigned variant called SYSDATE -1 bcoz it will update the database table for all the plants for the previous date. can anybody guide me that whether i should use the variable SYSDATE- 1 or the sy-datum-1 ,so that uploading the data can be performed.

    These are few options you may try
    1. Create a wrapper program which will first modify date in variant and save it again. FM RS_VARIANT_CONTENTS, RS_CHANGE_CREATED_VARIANT and
    RS_CREATE_VARIANT, RS_VARIANT_DELETE will be useful.
    Submit program with this changed variant.
    2. Same as above except variant change program can be scheduled and dependent step can be created to run from that variant.
    3. While saving the variant you may assign "Selection Variable". This will fetch data from table TVARVC. You will need to periodically update value of your date field in this table.
    Regards,
    Mohaiyuddin

  • SYSDATE is not getting incremented in the parameter - Scheduler

    Hi All
    I have used the query 'SELECT SYSDATE FROM DUAL' for a parameter in concurrent request. If I execute this concurrent as a single request, then it returns exact sysdate (current date) in a parameter.
    If i schedule this program for daily execution using scheduler, then the sysdate is always giving value of the date when i have configured the scheduler (even I have enabled the check box increment date parameters each run).
    For example,
    My Requirement :The scheduler configured such a way that it should run everyday.Whenever it runs my query has to return the current date.
    Current Issue: I schedule the scheduler on 23-Dec-2008. If it runs on 24-DEC-2008,it returns as '23-DEC-2008', If it runs on 28-DEC-2008 also,it returns as '23-DEC-2008.However If I execute this as a single request, it works fine.
    Can anyone help me please,,It is very urgent.
    Thanks in Advance

    Hi,
    This forum is dedicated to the Oracle Scheduler which uses the dbms_scheduler package.
    It looks like you might be using a different scheduler since the Oracle Scheduler does not allow using a query as a parameter and does not have an "increment date parameters" checkbox.
    If you are using the Oracle Applications Scheduler, you should ask this question on the Applications forum here
    http://forums.oracle.com/forums/category.jspa?categoryID=3
    If you are using the Enterprise Manager Scheduler you should ask on the Grid Control forum here
    Enterprise Manager
    If you are using the Oracle Scheduler you should post the code being used to create your job which may be found by using the "Show SQL" button on the create job webpage. This should include a call to dbms_scheduler.create_job .
    Thanks,
    Ravi.

  • Unit Testing: Supplying SYSDATE on a DATE parameter

    hi all,
    I have a procedure that I'm unit testing and one of the parameter is date, I want to supply a dynamic value to it relative to sysdate but SQL Developer only accepts hard coded date values. Does anyone know how I can supply SYSDATE or SYSDATE-50 to a date parameter directly. I can already solve this by using a wrapper procedure, just wondering if there's a solution to directly supply the value.
    Thanks,
    Alfredo

    Hi Kranthi.
    1. Assuming you are with Plus you can make the parameters optional in the parameters screen (tools -> parameters)
    so that if they get NULL as value they will return all data.
    2. the second way is if you like to keep it mandatory is to define a default value for the parameter and then take care of the situation in the condition.
    for example you'll define the 1-Jan-1900 as your default date for the from_date.
    Then in the condition change if you'll define it just as from_date > :P_from_date then you got what you wanted.
    BTW In similar situations when you are dealing with varchar you can do a manipulation such as:
    from_date > :P_from_date
    Or
    :P_from_date = '1-Jan-1900'
    Tamir

  • Passing sysdate in milliseconds from OAF page to PL/Sql proc

    Hi All,
    I have a requirement wherein I need to pass SYSDATE in milliseconds from OAF page to the PL/SQL package.
    Basically I will be calling a PL/SQL api from AM . So here I need to pass SYSDATE in milliseconds as one of the PL/SQL proc parameters.
    How do you I go about this ?
    Any help is aprreciated.
    Thanks in Advance

    get the current database date by
    oracle.sql.date currentDate=OADBTransaction's method getCurrenctDBDate ()
    (OADBTransaction object can be obtained from AM Object itself).
    Now you may convert this currentDate to java date object.
    currentDateObjAsJavaDate=currentDate.toDate()
    now miliseconds (since1970, I remember so, please see documentation) =currentDateObjAsJavaDate.getTime();

  • How to use SYSDATE as a default value of a bind variable in a query report?

    Hi,
    I want to use SYSDATE as default value for a bind variable in Query based report.
    I don't see any way to do it, someone helps?
    Thanks a lot.
    Paulo.

    You can aslo use #sysdate directly.
    Hi,
    The way I'm doing in my report is, I have a database function (f_ret_sysdate) with the following code
    create function f_ret_sysdate return varchar2
    begin
    return to_char(sysdate,'mm/dd/yyyy');
    end;
    Now, in the 'Customization Form Display Options' section of the report I'm calling this function as #f_ret_sysdate in the default value field of corresponding bind variable to display SYSDATE with the format.
    Hope this helps!...
    -Krishnamurthy

  • Setting sysdate as default date in oamessagedateinput bean

    hi all,
    I have to set sysdate in the oamessagedateinput bean, when the page is rendered.
    For that i have created a vo with query:
    select sysdate from dual;
    i have attached this sysdate attribute with oamessagedateinput bean. Still when the page is rendered the oamessagedateinput bean, is empty?
    can anybody help on this? y this is happening?

    u609740 ,
    I solved this problem long back....:)! Also written a small article on the same for others' refrence:
    http://mukx.blogspot.com/2007/11/setting-default-selected-date-for.html
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Title parameter: replacing sysdate with actual date

    i have 2 parameters:say,
    from_date = 10/OCT/2006 , to_date = SYSDATE
    and what i'm trying to acheive is to print the parameters in the report TITLE.
    when i use '&parameters' i see for to_date = SYSDATE instead i want to see the actual date the when the report was run.
    is there a way i can do it...?

    Michael brings up a fun little point.
    Years ago, I used to extoll to users that parameters, calculations, etc. had to follow a standard (ie: calculations were labelled like: calc_today_date, calc_gl_code_fixed, etc., and parameters were labelled such as: parm_plant_code or parm_employee_name, etc.).
    I then started teaching that as you don't see the parameter, you could label it however you like: ie: i_hate_my_job, my_boss_is_stupid, etc.
    Boy was it fun when I discovered that if you chose to display the parameters in the title, you'd get the parameter label as well!
    Suffice it to say, I do what Michael suggests. Create a parameter name with something that let's you display it - where the name says what it is (ie: from date, gl code, etc.).
    Maybe at some point in the future, Oracle will add the concept of what's in the EUL for item properties, wherein you have a parameter id (where you could put in text what it really is) and a parameter label (how you want it displayed).
    Russ

  • The value of sysdate function is sometimes not equal with O/S date.

    Hello, everyone.
    I administrate oracle 8i database that consists of OPS.
    The problem is that the value of sysdate function is not matched to OS date.
    It's runing commonly in equal state. but sometimes occurred, and the gap is one hour or one date.
    There are not any other logs and traces in the distination of oracle dump.
    So I can not detect what oracle event is happened on that time which the problem is occurred.
    Is there oracle event in this case?
    Could you reply to this problem?
    OS ver : HPUX 11.11
    DB ver : 8.1.7.4 OPS

    Please look into metalink note 1017965.102 for this
    You may need to change some settings in the System level to reset the Timde differential factor

  • How to get automatically sysdate in a field

    How to get sysdate automatically in a field in ADF

    As provided in the above blog post provided by Branislav,
    use the groovy expressions for defaulting the date using the following expressions is the right & recommended approach:
    Only date: adf.currentDate
    Date with Time: adf.currentDateTime
    see section 3.6.1 in ADF Developer's guide:
    http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcintro.htm#CEGJJJBA
    Thanks,
    Navaneeth

  • Create a trigger to check inserted date is before or after SYSDATE

    Hi,
    I am trying to create a trigger that will check an inserted date against SYSDATE and alter the value (i.e. make it SYSDATE) when the entered date is incorrect.
    For example, I have a Customer table with a record named MemberDate which, when a date is entered to it, will be checked by the trigger to ensure it is not before the current date.
    My code so far;
    CREATE OR REPLACE TRIGGER Customer
    BEFORE INSERT ON
    Customer
    FOR EACH ROW
    DECLARE
    e_invaliddate_ud EXCEPTION;
    BEGIN
    IF :NEW.MemberDate < SYSDATE THEN
    RAISE e_invaliddate_ud;
    END IF;
    EXCEPTION
    WHEN e_invaliddate_ud THEN
    DBMS_OUTPUT.PUT_LINE('The date entered for MemberDate is invalid. The
    MemberDate has been set to the current date');
    END;
    So far, this trigger only returns an error message but allows the date to be entered even if it is incorrect. I have tried a few ways of altering the entered date to SYSDATE but to no avail.
    I am running scripts using SQL PLUS and inserting data using
    INSERT INTO Customer
    VALUES(CustomerID, ..., MemberDate);
    Where the values entered will be checked to ensure the MemberDate is not before SYSDATE.
    The MemberDate data-type is DATE and has a rule that it must not be before the current date. I am aware that a constraint may not be used to perform a check using SYSDATE, this is why I am trying to make a trigger.
    However, my knowledge of triggers is limited
    If anyone can help, I will be very Happy.
    Thank you in advance.

    Use this if you want an error message that halts the execution:
    create or replace trigger customer
    before insert on customer
    for each row
    begin
      if :new.memberdate < sysdate
      then
        raise_application_error(-20000,'The date entered for MemberDate is invalid.');
      end if;
    end;Use this if you want to automatically to overwrite the MemberDate with sysdate without an error message:
    create or replace trigger customer
    before insert on customer
    for each row
    begin
      :new.memberdate := greatest(sysdate,:new.memberdate);
    end;Note: untested
    Regards,
    Rob.

  • Insert sysdate value to date type column in DB

    Hi All
    I need you help. How to set Last_Update_Date to a default date in sql… For example when a user runs the query, the query show display only those values which got changed as of that day’s date. For Example. If I run the query on May 22nd the query show display only that data which got last updated on May 22nd.Can we use INSER INTO. If so ow to insert Last_update_date = sysdate in the below query.
    select hzp.creation_date,fnd.user_id,hzp.party_id,fnd.user_name,
    hzp.person_first_name,hzp.person_last_name,hzl.address2,hzl.address3,hzl.city,
    hzl.postal_code,hzl.state,hzp.last_update_date,frt.responsibility_name
    from APPLSYS.fnd_responsibility_tl frt,APPS.fnd_user_resp_groups fur,
    APPLSYS.fnd_user fnd,AR.hz_parties hzp,AR.hz_party_sites hzps,AR.hz_locations hzl
    where fnd.user_id = fur.user_id
    and fur.responsibility_id = frt.responsibility_id
    and hzp.party_id = fnd.person_party_id
    and hzp.party_id = hzps.party_id
    and hzps.location_id = hzl.location_id
    and last_updated_date = ''
    Regards

    To have last_update_date automatically filled in, your best option is to create a trigger on the table that sets that field to sysdate every time any other field in the row is updated.
    Something like this:
    TRIGGER "TRIGGERNAME" AFTER INSERT OR UPDATE ON FIELD ON "TABLENAME" FOR EACH ROW
    BEGIN
    IF :new.FIELD_NAME IS NULL THEN
    SELECT SYSDATE INTO :new.FIELD_NAME FROM DUAL;
    END IF;
    END;
    To query off that field, you probably want to use trunc(last_update_date)=trunc(sysdate) which causes Oracle to basically ignore the time and only look at the date.

  • What's wrong with my code for comparing date retreived from db and sysdate?

    Hi all,
    I need to retrive date from the DB and compare it to system date.i have posted the code below.i get java.sql.SQL Exception:Io exception:Socket closed.
    What's wrong with the code?please help me.Thanks in advance.
    public boolean date() throws IOException, SQLException {
    Connection con1;
    long millis = System.currentTimeMillis();
    Timestamp timestamp = new java.sql.Timestamp(millis);
    ResultSet rs4 = null;
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection(
    "jdbc:oracle:thin:@abc:1605:xyz",
    "cdf", "cdf");
    Statement stmt_exp = con.createStatement();
    rs4 = stmt_exp.executeQuery("SELECT DATE FROM TABLE_NAME")
    while (rs4.next()) {
    Timestamp timestamp2 = rs4.getTimestamp("expire_date");
    con1.close();
    catch (Exception e)
    e.printStackTrace();
    finally
    //ResultSet rs4 = null;
    //Timestamp timestamp2;
    Timestamp timestamp2 = rs4.getTimestamp("expire_date");
    if (timestamp2.compareTo(timestamp) < 0)  //sysdate < exp date
    return true;
    } else {
    return false;
    }

    Didn't you understand what BalusC said? You're closing the connection and then trying to use the ResultSet. The ResultSet will be closed when you close the connection so you can't use it anymore.
    You should close the connection last thing in your code, probably in a finally. And after you close your ResultSet and Statement.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

  • How to get the current week from sysdate?

    Hi sir,
    i want to know how to get the current week from sysdate?
    thanks

    Hi Nicolas
    It seems you like to check my post and also make commend ;) thanks for your attention
    Have you ever read the posts above and given solutions ?Yes, I did
    Have you read the docs ? Yes, I checked
    What's the added value here ?Did youYou shared doc with solution(long one), I shared short one which point same solution(Check what Joel posted)..So what is benefit, As you can guess oracle docs are sometimes become so complicated as specialy for beginner...(At least it was like that for me and Belive me somedocs are still sooo complicated even for oracle coworkers ) But for you I dont know ;)
    => Why writting the PS in bold ?Why.. Let me think... Ohh Maybe I am looking some questions(many) and even user get answer they should not changed status so I am reading some posts and try to get problem and loosing time..
    So I am putting that PS wiht BOLD because I dont wanna lose time my friend ;) Because While I am trying to help ppl here In same time I am trying to giving support to my customer prod systems. Which mean time is very important for me...
    Hope my answer could satisfy you..
    One important PS for you.. You may not like my posts (or someone) but my friend I become tired to read&answer and make commend to on your comment which is about my posts.
    I am not newbie in forum(At least I fell like that) and I belive I know how I should make post..
    Thank you
    Regards
    Helios

Maybe you are looking for

  • Urgent :ALV layout change not  working

    hi experts, i copied the tcode FBL5N into ztcode. added some more fields to the ALV output. using GUI STATUS 'ALV_ITEMS_AR' when i select the change layout from using application button, added some more columns. Data is picking correctly, but i dont

  • Weird Bounce-back of an email address that is not even in my contacts!

    Hey folks, Recently I have been getting a bounced back email from an address that is not even in my contacts (I use outlook). It's only when I send an email to a particular person. She gets the email, but I get this bounce back from a SIMILAR email.

  • Broken DCs in ESS Track when upgraded to JDI SP16

    Hi, Track Information – Name – ESSTrack Business Package – SAP_ESS Release 100 SP7 WAS 6.40 SP 16 JDI – SP16 We have recently upgraded our JDI from SP11 to SP16. We already had a track configured for ESS SP7 in which we have made MANY CUSTOM MODIFICA

  • Asset Intelligence per site licenses

    Hello everyone! I have a question on the following scenario: One CAS on the parent company (in Europe) and two primary sites (both in South America). I need to configure Asset Intelligence on this environment, the catch is that each country has to ha

  • Logs in weblogic while starting a server

    I have added adf and jsf jar files (afc.jar,jsf-impl.jar,jstl.jar,adf-faces-api.jar,adf-faces-impl.jar,adfshare.jar,commons-beanutils.jsr,commons-collections.jar,commons-digester.jar,,jsf-api.jar,standard.jar) under web-inf /lib folder in my project