SYSDATE+(60*24)/1440

SYSDATE+(60*24)/1440
What is the exact date and time of this conversion?

user8674910 wrote:
hi,
my sysdate is 18-jan-10 01:00:00
based on this formula the output is given below: (SYSDATE+(60*24)/1440 )
20-jan-10 13:00:00 P.M
60 is hr
24 is min ( 24 * 60 sec =1440 seconds )
1440 is minutesYou appear to have done something wrong if you truly got that output. You also appear to have a few misconceptions over what the above formula represents.
Date differences in Oracle are measured in terms of the number of days. In order to convert that into hours, you have to multiply by 24, to convert that into minutes, you have to multiply by 24*60 (1440) and to convert to seconds, multiply by 24*60*60.
eg:
(date1 - date2) = diff_in_days
=> date1 = date2 + diff_in_days
diff_in_hours = diff_in_days * 24
diff_in_minutes = diff_in_days * 24 * 60
diff_in_seconds = diff_in_days * 24 * 60 * 60
=> diff_in_days = diff_in_hours / 24 = diff_in_minutes / (24 * 60) = diff_in_seconds / (24 * 60 * 60)Therefore when you want to add minutes onto a date, you would use the "diff_in_minutes / (24 * 60)" format, and in the OP's example, that works out to be 1440 / 1440 which is the same as saying 1 day.
So your result can't possibly have been correct; if you think it was, please recreate in SQL*Plus and copy the resultant commands, like:
SQL> alter session set nls_date_format='dd/mm/yyyy hh24:mi:ss';
Session altered.
SQL> select sysdate, sysdate + (60*24)/1440 from dual;
SYSDATE             SYSDATE+(60*24)/144
18/01/2010 11:27:20 19/01/2010 11:27:20
1 row selected.

Similar Messages

  • How to find out the rows inserted in the last n minutes ?

    Hi all,
    I have a log table where, every time a warning is issued, a new row is added. The table has a field with the sysdate when the warning was issued.
    I'd need to collect all warnings in the last (supposing) 30 minutes and send a mail to the administrator. Looking at some faqs I have elaborated this:
    select * from PROCEDURE_LOGS p where ((p.DATE_LOG - sysdate)*-1440) < 30
    However this does not produce anything.
    Can anybody help me to correct this statement ?
    Thanks a lot
    Frank

    Hi, Frank,
    That looks okay to me. Are you sure you have rows in the table with a date_log in the last 30 minutes? Post some sample data (CREATE TABLE and INSERT statements), and the results you expect from that data for a given value of SYSDATE.
    By the way, you can make the WHERE clause clearer like this:
    select     *
    from      PROCEDURE_LOGS     p
    where      ( (sysdate - p.DATE_LOG)
         * 1440           -- = 24 * 60
         ) < 30but this won't change the results.
    Edited by: Frank Kulash on Dec 1, 2010 9:51 AM
    I just saw Toon's reply:
    where     p.DATE_LOG > sysdate - (30 / 1440)as Toon suggested, is clearer still, and potentially more efficient if ther's an index on date_log.

  • Oarcle Lite cannot subtract negative numbers from date

    Hello
    we have a very strange problem. We have a query that need to convert times between different timezones. So, we have
    In Oracle lite, the query
    select sysdate - (-60/1440) nd from dual returns sysdate + 2 - 60/1440.
    Whenever a negative fraction is subtracted from date, it always adds two days and then adds the fraction. Looks like negative of a negative fraction is not handled correctly in oracle lite.
    Did anyone encounter this problem? We have the system in production and wondering if anyone found a solution.
    Thanks

    HI sd,
    I suspect there's a simpler way, but this works, as seen in the example. Start and finish times are both incremented by one day as the data and formula are filled down the columns to show the effect of crossing the weekend days. Formula (as it appears in row 7) is shown above the table. The Row 2 version is copied below. Cels in column D are formatted as shown in the Inspector.
    D2: =NETWORKDAYS(B2,C2,)+DURATION(,,24*(DUR2DAYS(C2-B2)-INT(DUR2DAYS(C2-B2))),,,)
    Regards,
    Barry

  • Need To use SQL Code to Appt Dates 2 Days from current Getting Error

    I am trying to pull data that shows appt information on a patient:
    FName,LName, PhoneNumber, ApptDate, ApptTime, and Status that equals Active. I need to pull this info everyday. How can I set this up in a stored procedure to pull all this information automatically on a daily basis where it pulls by Appt Date that is 2 days greater than the current date?
    SELECT
         Patient.First,
         Patient.Last,
         Patient.HomeArea,
         Patient.HomePhone,
         Patient.Status,
         ApptHis.Date,
         ApptHis.Time
    From
         Patient, ApptHis
    Where
         Status= 'Active' and
         ApptHis.ApptHisDate >= dateadd(day,datediff(day,0,getDate())+2,0)     and
         ApptHis.ApptHisDate < dateadd(day,datediff(day,0,getDate())+3,0)
    Please Help I am getting an ORA-00900 Error.
    Thanks!

    In your select statement you specify the column ApptHis.Time but it looks like in the database the actual column name is Time1.
    Also, Date is a reserve word in Oracle. It's a really bad idea to create columns using reserve words. You may have to use double quotes (i.e. "Date") to specify the column name Date in your selects.
    Try this:
    SELECT
    Patient.First,
    Patient.Last,
    Patient.HomeArea,
    Patient.HomePhone,
    Patient.Status,
    ApptHis.Date,
    ApptHis.Time1
    From
    Patient, ApptHis
    Where
    Status= 'Active' and
    ApptHis.ApptHisDate between trunc(sysdate+2) and trunc(sysdate+3)-1/1440;
    NumbNutz

  • Need to retrieve last 10 minutes records from database

    Hi ,
    I am Srinivas, I want to retrieve calls done in last 10 min for that i had a query
    select count(*) as a from ONLINE_BALANCE where DATETIME >= SYSDATE - INTERVAL '10/1440' HOUR;
    It is giving a error;
    Can you suggest me with necessary modifications.

    Hi ,
    I am Srinivas, I want to retrieve calls done in last
    10 min for that i had a query
    select count(*) as a from ONLINE_BALANCE where
    DATETIME >= SYSDATE - INTERVAL '10/1440' HOUR;
    It is giving a error;
    Can you suggest me with necessary modifications.
    ... where DATETIME >= SYSDATE - INTERVAL '10' MINUTE;RTFM:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements003.htm#sthref372
    pratz

  • SQL -Reply

    We use Dynamic SQL for returning several rows as well as only one
    row. Set up a textdata variable and use it's concat() method to construct
    the desired SQL statement:
    DynamicSQLStatement: TextData = new ;
    DynamicSQLStatement.SetValue('select id_num, ') ;
    DynamicSQLStatement.Concat('lst_name, ') ;
    DynamicSQLStatement.Concat('fst_name, ') ;
    DynamicSQLStatement.Concat('brth_dte, ') ;
    DynamicSQLStatement.Concat('ssn, ') ;
    ---------------------- If SSN entered -----------------------
    if SSN.isDigit then
    DynamicSQLStatement.Concat('where ssn = ') ;
    DynamicSQLStatement.Concat(SSN.IntegerValue);
    DynamicSQLStatement.Concat(' ');
    else
    if NamePattern then
    DynamicSQLStatement.Concat('where lst_name like ');
    DynamicSQLStatement.Concat('''').Concat(HoldName).Concat('%').Concat(''' ') ;
    CheckFirstName() ;
    CheckBirthdate() ;
    else
    DynamicSQLStatement.Concat('where lst_name = ') ;
    DynamicSQLStatement.Concat('''').Concat(HoldName).Concat(''' ') ;
    CheckFirstName() ;
    CheckBirthdate() ;
    end if ;
    end if ;
    and so on.... Read up on DBSession class to prepare sql, open, fetch, &
    close cursors.
    dynStatement = var_session.Prepare (commandString = SQLselect,
    inputDataSet=inputDescriptor,
    cmdType =
    statementType) ;
    begin
    rowType = var_session.OpenCursor(statementHandle =
    dynStatement,
    inputDataSet =
    inputDescriptor,
    resultDataSet =
    outputDescriptor) ;
    while true do
    numRows = var_session.FetchCursor(statementHandle =
    dynStatement,
    resultDataSet = outputData) ;
    if numRows <= 0 then
    exit ;
    else
    myobj.lst_name=TextData(outputData.GetValue(position = 2)) ;
    myobj.fst_name=TextData(outputData.GetValue(position = 3)) ;
    myobj.brth_dte=DateTimeData(outputData.GetValue(position = 4)) ;
    myobj.ssn=IntegerNullable(outputData.GetValue(position = 5)) ;
    etc, etc...
    To retrieve just one row...
    numRows = var_session.Select(statementHandle = dynStatement,
    inputDataSet =inputDescriptor,
    resultDataSet= outputData,
    maxRows=1) ;
    if numRows <= 0 then
    ReturnCount.Value = 0;
    else
    ReturnCount=IntegerData(outputData.GetValue(position=1)
    end if ;
    Let me know if I'm way off base here. :)
    Steven Barnes
    IDPA
    MOTTA 11/19/96 07:32am >>>Forte Users,
    I would like to know if its possible to build an SQL select at run
    time. That is, to concat to a textdata and run as SQL that textdata.
    If its not possible, is there any other ideia of how we could do
    it?

    with rt as 
    (select 1 sno ,sysdate sdate from dual union all 
    select 2,sysdate - (1/(1440*60)) from dual union all 
    select 3,sysdate - (1/(1440)) from dual union all 
    select 4,sysdate - (30/(1440)) from dual union all 
    select 5,sysdate -1+(1/(1440*60)) from dual union all
    select 6,sysdate -1-(1/(1440*60)) from dual)
    select sysdate,a.* from rt a;
    Row#     SYSDATE     SNO     SDATE
    1     01-Aug-2007 2:32:06 PM     1     01-Aug-2007 2:32:06 PM
    2     01-Aug-2007 2:32:06 PM     2     01-Aug-2007 2:32:05 PM
    3     01-Aug-2007 2:32:06 PM     3     01-Aug-2007 2:31:06 PM
    4     01-Aug-2007 2:32:06 PM     4     01-Aug-2007 2:02:06 PM
    5     01-Aug-2007 2:32:06 PM     5     31-Jul-2007 2:32:07 PM
    6     01-Aug-2007 2:32:06 PM     6     31-Jul-2007 2:32:05 PM
    with rt as 
    (select 1 sno ,sysdate sdate from dual union all 
    select 2,sysdate - (1/(1440*60)) from dual union all 
    select 3,sysdate - (1/(1440)) from dual union all 
    select 4,sysdate - (30/(1440)) from dual union all 
    select 5,sysdate -1+(1/(1440*60)) from dual union all
    select 6,sysdate -1-(1/(1440*60)) from dual)
    select sysdate,a.* from rt a where  sdate >= sysdate - 1;
    Row#     SYSDATE     SNO     SDATE
    1     01-Aug-2007 2:32:12 PM     1     01-Aug-2007 2:32:12 PM
    2     01-Aug-2007 2:32:12 PM     2     01-Aug-2007 2:32:11 PM
    3     01-Aug-2007 2:32:12 PM     3     01-Aug-2007 2:31:12 PM
    4     01-Aug-2007 2:32:12 PM     4     01-Aug-2007 2:02:12 PM
    5     01-Aug-2007 2:32:12 PM     5     31-Jul-2007 2:32:13 PM

  • Sql Query-Reply quickly ..pls

    I have 3 tables:
    CREATE TABLE MARKET (
    MARKET_ID INTEGER NOT NULL,
    MARKET_DEFINITION_ID     INTEGER NOT NULL,
    MARKET_DATE     TIMESTAMP NOT NULL,
    MARKET_HOUR     INTEGER,
    MDS_UPDATE_DTS TIMESTAMP NOT NULL,
    MDS_UPDATE_USER VARCHAR2(30) NOT NULL,
    PRIMARY KEY (MARKET_ID),
    CREATE TABLE EVENT_DEFINITION (
    EVENT_DEFINITION_ID INTEGER NOT NULL,
    EVENT_DESC VARCHAR2(255) NOT NULL,
    DIRECTIVE VARCHAR2(30) NOT NULL,
    EVENT_TIME_OFFSET INTEGER NOT NULL,
    OFFSET_UNITS VARCHAR2(10) NOT NULL,
    PRIMARY KEY (EVENT_DEFINITION_ID));
    CREATE TABLE MARKET_EVENT_HISTORY (
    MARKET_EVENT_HISTORY_ID INTEGER NOT NULL,
    EVENT_DEFINITION_ID INTEGER NOT NULL,
    MARKET_ID INTEGER NOT NULL,
    MDS_INSERT_DTS TIMESTAMP NOT NULL,
    PRIMARY KEY (MARKET_EVENT_HISTORY_ID),
    FOREIGN KEY (MARKET_ID)REFERENCES MARKET,
    FOREIGN KEY (EVENT_DEFINITION_ID) REFERENCES EVENT_DEFINITION);
    COMMIT;
    and the data in the :
    MARKET_EVENT_HISTORY will be some thing like this:
    MARKET_EVENT_HISTORY_ID MDS_INSERT_DTS
    "1",                     "31-JUL-02 09.00.00.123000 AM"
    "2",                     "30-JUL-07 08.00.00.000000 AM"
    "3",                    "30-JUL-07 11.00.00.000000 PM"
    "4",                    "31-JUL-07 12.00.00.000000 PM"
    "5",                     "31-JUL-07 11.00.00.000000 PM"
    "6",               "31-JUL-07 10.00.00.000000 PM"
    "7",                     "31-JUL-07 07.00.00.000000 PM"
    "8",                     "31-JUL-02 01.00.00.123000 AM"
    "9",                     "30-JUL-02 01.00.00.123000 AM"
    "10",                    "30-JUL-02 06.00.00.123000 AM"
    "11",                    "31-JUL-02 04.00.00.123000 AM"
    "21",                "31-JUL-02 03.00.00.123000 AM"
    and assume rest of the columns is having some data.
    I want 5 columns from the above 3 tables
    From Market Table
    MARKET_DATE     TIMESTAMP NOT NULL,
    MARKET_HOUR     INTEGER,
    From Event definiton table
    OFFSET_UNITS VARCHAR2(10) NOT NULL
    From Market event history table
    MDS_INSERT_DTS
    i want a query for all the 5 columns with the help of join .
    But the conditon is :
    Based upon MDS_INSERT_DTS i need to retreive the last 24 hours records in the data base.
    Assume MDS_INSERT_DTS is sysdate.
    Ex:
    Suppose the sysdate is
    31-JUL-07 10.00.00.000000 PM"
    then the last 24 hours records available in the data base(MDS_INSERT_DTS ) should be retrieved like below.
                        "30-JUL-07 08.00.00.000000 AM"
                        "31-JUL-02 09.00.00.123000 AM"
                        etc all the records of the last 24 hours has to be retrevied .
    we have the relation ship between the tables in Market_Event_History.
    send me the reply immediately...plssssssssssssss..........urgent

    with rt as 
    (select 1 sno ,sysdate sdate from dual union all 
    select 2,sysdate - (1/(1440*60)) from dual union all 
    select 3,sysdate - (1/(1440)) from dual union all 
    select 4,sysdate - (30/(1440)) from dual union all 
    select 5,sysdate -1+(1/(1440*60)) from dual union all
    select 6,sysdate -1-(1/(1440*60)) from dual)
    select sysdate,a.* from rt a;
    Row#     SYSDATE     SNO     SDATE
    1     01-Aug-2007 2:32:06 PM     1     01-Aug-2007 2:32:06 PM
    2     01-Aug-2007 2:32:06 PM     2     01-Aug-2007 2:32:05 PM
    3     01-Aug-2007 2:32:06 PM     3     01-Aug-2007 2:31:06 PM
    4     01-Aug-2007 2:32:06 PM     4     01-Aug-2007 2:02:06 PM
    5     01-Aug-2007 2:32:06 PM     5     31-Jul-2007 2:32:07 PM
    6     01-Aug-2007 2:32:06 PM     6     31-Jul-2007 2:32:05 PM
    with rt as 
    (select 1 sno ,sysdate sdate from dual union all 
    select 2,sysdate - (1/(1440*60)) from dual union all 
    select 3,sysdate - (1/(1440)) from dual union all 
    select 4,sysdate - (30/(1440)) from dual union all 
    select 5,sysdate -1+(1/(1440*60)) from dual union all
    select 6,sysdate -1-(1/(1440*60)) from dual)
    select sysdate,a.* from rt a where  sdate >= sysdate - 1;
    Row#     SYSDATE     SNO     SDATE
    1     01-Aug-2007 2:32:12 PM     1     01-Aug-2007 2:32:12 PM
    2     01-Aug-2007 2:32:12 PM     2     01-Aug-2007 2:32:11 PM
    3     01-Aug-2007 2:32:12 PM     3     01-Aug-2007 2:31:12 PM
    4     01-Aug-2007 2:32:12 PM     4     01-Aug-2007 2:02:12 PM
    5     01-Aug-2007 2:32:12 PM     5     31-Jul-2007 2:32:13 PM

  • Very slow running SQL

    Hello I have a stored procedure that I am using to load 5 tables from a stagin table. It reads each line and populates these tables. The staging table has 200K rows in it and I commit every 10,000 rows. Once released to production the staging table will have around 23 million rows in it to be processed. It is running very poorly. I am running Oracle 9.2.0.6. Here is the stored procedure. Any suggestions on how to make it faster. Is there a way to use bulk binding/insert and would that be better?
    Thank you,
    David
    CREATE OR REPLACE procedure SP_LOAD_STAGED_CUST (runtime_minutes int)
    is
    staged_rec STAGE_CUSTOMER%ROWTYPE;
    end_time          date     default sysdate + (nvl(runtime_minutes,1440)/1440);
    test_row_id     number(38);
    in_table_cnt     number(38);
    BEGIN
    -- POPULATE LOCATION AND ASSOCIATE TABLES AS NEEDED
    insert into TMP_LOCATION (update_location_cd, country_cd, locale_cd)
    select      distinct update_location_cd,
         country_cd,
         locale_cd
    from stage_customer
    update TMP_Location
    set location_id = location_seq.nextval
    insert /*+ APPEND */ into location
    ( location_id, location_cd, location_desc, short_description, sales_channel_id, location_type_id,
    location_category_id, addr1, addr2, addr3, city, state_cd, postal_cd, country_cd, region_id,
    timezone_id, locale_cd, currency_cd, phone_num, alt_phone_num, fax_num, alt_fax_num,
    email_addr, alt_email_addr, is_default, create_modify_timestamp)
    select
    location_id,
    update_location_cd,
    null,
    null,
    fn_sales_channel_default(),
    null,
    null,
    null, null, null,
    null, null, null ,
    nvl(country_cd, 'USA'),
    null, null,
    locale_cd,
    'USD',
    null, null, null, null, null, null,
    0,
    sysdate
    from TMP_LOCATION
    where update_location_cd not in (select location_cd from location);
    commit
    insert into TMP_ASSOCIATE (associate_number, update_location_cd)
    select      associate_number, min(update_location_cd)
         from stage_customer
    where associate_number is not null
    group by associate_number;
    update TMP_ASSOCIATE
    set associate_id = associate_seq.nextval
    insert /*+ APPEND */ into associate
    select
    associate_id ,
    null,
    associate_number,
    (select nvl(location_id, fn_location_default())
         from location
         where location.location_cd = tmp_associate.update_location_cd)
    from TMP_ASSOCIATE
    where not exists (select associate_id from associate
              where associate.associate_number = tmp_associate.associate_number)
    delete from tmp_associate;
    commit;
    insert into TMP_ASSOCIATE (associate_number, update_location_cd)
    select      alt_associate_number, min(update_location_cd)
         from stage_customer
    where alt_associate_number is not null
    group by alt_associate_number
    update TMP_ASSOCIATE
    set associate_id = associate_seq.nextval
    insert /*+ APPEND */ into associate
    select
    associate_id ,
    null,
    associate_number,
    (select nvl(location_id, fn_location_default())
         from location
         where location.location_cd = tmp_associate.update_location_cd)
    from TMP_ASSOCIATE
    where not exists (select associate_id from associate
              where associate.associate_number = tmp_associate.associate_number);
    commit;
    select min(row_id) -1 into test_row_id from stage_customer ;
    WHILE sysdate < end_time
    LOOP
    select *
    into staged_rec
    from Stage_Customer
    where row_id = test_row_id + 1;
    if staged_rec.row_id is null
    then
    COMMIT;
    EXIT;
    end if;
    -- EXIT WHEN staged_rec.row_id is null;
    -- INSERTS TO CUSTOMER TABLE (IN LOOP - DATA FROM STAGE CUSTOMER TABLE)
    insert /*+ APPEND */ into customer (
         customer_id,
         customer_acct_num,
         account_type_id,
         acct_status,
         discount_percent,
         discount_code,
         uses_purch_order,     
         business_name,
         tax_exempt_prompt,
         is_deleted,
         name_prefix,
         first_name,
         middle_name,
         last_name,
         name_suffix,
         nick_name,
         alt_first_name,
         alt_last_name,
         marketing_source_id,
         country_cd,
         locale_cd,
         email_addr,
         email_addr_valid,
         alt_email_addr,
         alt_email_addr_valid,
         birth_date,
         acquisition_sales_channel_id,
         acquisition_location_id,
         home_location_id,
         salesperson_id,
         alt_salesperson_id,
         customer_login_name,
         age_range_id,
         demographic_role_id,
         education_level_id,
         gender_id,
         household_count_id,
         housing_type_id,
         income_range_id,
         lifecycle_type_id,
         lifetime_value_score_id,
         marital_status_id,
         religious_affil_id
    values (      
         staged_rec.row_id,
         staged_rec.customer_acct_num,
         nvl(staged_rec.account_type_id, fn_account_type_default()),
         1,
         staged_rec.discount_percent,
         staged_rec.discount_cd,
         staged_rec.pos_allow_purchase_order_flag,
         staged_rec.business_name,
         staged_rec.pos_tax_prompt,
         staged_rec.is_deleted,
         staged_rec.name_prefix,
         staged_rec.first_name,
         staged_rec.middle_name,
         staged_rec.last_name,
         staged_rec.name_suffix,
         staged_rec.nick_name,
         staged_rec.alt_first_name,
         staged_rec.alt_last_name,
         staged_rec.new_marketing_source_id,
         staged_rec.country_cd,
         staged_rec.locale_cd,
         staged_rec.email_addr,
         nvl2(staged_rec.email_addr,1,0),
         staged_rec.alt_email_addr,
         nvl2(staged_rec.alt_email_addr,1,0),
         staged_rec.birth_date,
         staged_rec.SALES_CHANNEL_ID,
         (select location_id from location where location_cd = staged_rec.update_location_cd),
         (select location_id from location where location_cd = staged_rec.update_location_cd),
         (select min(a.associate_id) from associate a
              where staged_rec.associate_number = a.associate_number
              and a.location_id =
                   (select location_id from location where location_cd = staged_rec.update_location_cd)),
         (select min(a.associate_id) from associate a
              where staged_rec.alt_associate_number = a.associate_number
              and a.location_id =
                   (select location_id from location where location_cd = staged_rec.update_location_cd)),
         staged_rec.customer_login_name,
         fn_age_range_default(),
         fn_demographic_role_default(),
         fn_education_level_default(),
         fn_gender_default(),
         fn_household_cnt_default(),
         fn_housing_type_default(),
         fn_income_range_default(),
         fn_lifecycle_type_default(),
         fn_lifetime_val_score_default(),
         fn_marital_status_default(),
         fn_religious_affil_default()
    -- INSERTS TO PHONE TABLE ( IN LOOP -DATA FROM STAGE CUSTOMER TABLE)
    if staged_rec.home_phone is not null
    then
    insert /*+ APPEND */ into phone ( customer_id, phone_type_id, phone_num, is_valid, is_primary)
         values (staged_rec.row_id, 1, staged_rec.home_phone, 1, 1);
    end if;
    if staged_rec.work_phone is not null
    then
    insert /*+ APPEND */ into phone (customer_id, phone_type_id, phone_num, is_valid,is_primary)
         values (staged_rec.row_id, 2, staged_rec.work_phone, 1, 0);
    end if;
    if staged_rec.mobile_phone is not null
    then
    insert /*+ APPEND */ into phone ( customer_id, phone_type_id, phone_num, is_valid, is_primary)
         values (staged_rec.row_id, 3, staged_rec.home_phone, 1, 0);
    end if;
    if staged_rec.work_phone is not null
    then
    insert /*+ APPEND */ into phone (customer_id, phone_type_id, phone_num, is_valid,is_primary)
         values (staged_rec.row_id, 4, staged_rec.work_phone, 1, 0);
    end if;
    -- INSERTS TO CUSTOMER ADDR TABLE ( IN LOOP - DATA FROM STAGE CUSTOMER TABLE)
    if staged_rec.address1 is not null
    then
    insert /*+ APPEND */ into customer_addr (customer_id, address_type_id, address1, address2, address3, city, state_cd, postal_cd, country_cd, region_id,
                   is_primary, is_valid, cannot_standardize, is_standardized)
         values (staged_rec.row_id, fn_address_type_default(), staged_rec.address1, staged_rec.address2, staged_rec.address3,
              staged_rec.city, staged_rec.state_cd, staged_rec.postal_cd, staged_rec.country_cd, staged_rec.region, 1, 1, 0, 0);
    end if;
    -- INSERTS TO CUSTOMER_STATE_TAX_ID
    if staged_rec.pos_default_tax_id is not null
    then
    insert /*+ APPEND */ into customer_state_tax_id (state_cd, customer_id, tax_id, expiration_date)
         values (staged_rec.state_cd, staged_rec.row_id, staged_rec.pos_default_tax_id,
              staged_rec.pos_tax_id_expiration_date);
    end if;
    -- REMOVE STAGE CUSTOMER ROW (IN LOOP - DELETE CUSTOMER FROM STAGE_CUSTOMER TABLE)
    delete from stage_customer
    where row_id = staged_rec.row_id;
    -- COMMIT AFTER EVERY 10,000 CUSTOMERS
    if mod(staged_rec.row_id, 100) = 0
    then
    commit;
    end if;
    -- INCREMENT ROW ID TO BE RETRIEVED
    test_row_id := test_row_id + 1;
    END LOOP;
    EXCEPTION
         WHEN NO_DATA_FOUND
         THEN
         COMMIT;
    END;
    Message was edited by:
    JesusLuvR
    Message was edited by:
    JesusLuvR

    You want to do as much processing as you can in single large sql statements, not row by row. You also want to do as few statemetns as possible. Most of what you are doing looks to me like it could be done as a series of single sql statements. For example, the three statements that populate location ca nbe condensed to a single statement like:
    INSERT /*+ APPEND */ INTO location
       (location_id, location_cd, location_desc, short_description, sales_channel_id,
        location_type_id, location_category_id, addr1, addr2, addr3, city, state_cd,
        postal_cd, country_cd, region_id, timezone_id, locale_cd, currency_cd,
        phone_num, alt_phone_num, fax_num, alt_fax_num, email_addr, alt_email_addr,
        is_default, create_modify_timestamp)
    SELECT location_seq.NEXTVAL, update_location_cd, NULL, NULL,
           fn_sales_channel_default(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
           NVL(country_cd, 'USA'), NULL, NULL, locale_cd, 'USD', NULL, NULL, NULL,
           NULL, NULL, NULL, 0, sysdate
    FROM (SELECT DISTINCT update_location_cd, country_cd, locale_cd
          FROM stage_customer
          WHERE update_location_cd NOT IN (SELECT location_cd FROM location);You can easily do a similar change to the statemetns populating associates.
    I don't, off hand, see anything in the intert into customers that seems to require row by row processing. Just do it in a large insert. I would also be tempted to replace the many values of the form (select location_id from location where location_cd = staged_rec.update_location_cd) to a join with location. As far as I can see, you would only need one copy of location.
    I also notince that you have a number of function calls in the values list. I would look carefully at whether you need them at all, since they seem to have no parameters, so should return the same value every time. Minimally, I would consider calling them once each, storing the values in variables and use those variables in the insert.
    HTH
    John

  • Question about DBMS_JOB

    Hi , I have this job that I would like to modify so that it runs only from sunday to thursday and starts at 8:00 till 14:30.
    DECLARE
      X NUMBER;
    BEGIN
      SYS.DBMS_JOB.SUBMIT
        ( job       => X
         ,what      => 'update_port_prices;'
         ,next_date => sysdate
         ,interval  => '  SYSDATE  +  0.010416666666666666666666666666667 /* every quarter an hour */  '
         ,no_parse  => TRUE
      SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
    END;
    commit;

    Try this
    create or replace function next_execution return date as
    v_dt date;
    begin
    v_dt:= case when to_char(sysdate,'HH24MI') between  0800 and 1415 then
    trunc(sysdate,'MI')+15/1440
    when to_char(sysdate,'DY') in ('SUN','MON','TUE','WED') then
    trunc(sysdate)+1+8/24
    else next_day(trunc(sysdate),'SUN')+8/24 end;
    return v_dt;
    end;
    --Checking function output
    PRAZY@11gR1> select to_char(sysdate,'MM/DD/YYYY HH24:MI:SS') from dual;
    TO_CHAR(SYSDATE,'MM
    03/16/2010 16:46:00
    Elapsed: 00:00:00.00
    PRAZY@11gR1> select to_char(next_execution,'MM/DD/YYYY HH24:MI:SS') from dual;
    TO_CHAR(NEXT_EXECUT
    03/17/2010 08:00:00
    Elapsed: 00:00:00.00
    --job scheduling
    declare
    v_num number;
    begin
    dbms_job.submit(v_num,'update_port_prices;',sysdate,'next_execution()');
    dbms_output.put_line('Job Number :'||v_num);
    end;Regards,
    Prazy
    Edited by: Prazy on Mar 16, 2010 4:42 PM
    Removed THU as it has to run only from sunday to thursday & added sysdate in function test & fixed some typo's ;)

  • Combine Two table columns

    SELECT providerid, SUM(COUNT) FROM appdev.usercounts
    WHERE counttime BETWEEN SYSDATE - 30/1440 AND SYSDATE- 15/1440 GROUP BY providerid ORDER BY providerid
    W     697
    U     813
    T     143
    S     2
    SELECT providerid, SUM(COUNT) FROM appdev.usercounts
    WHERE counttime BETWEEN (SYSDATE -1) - 30/1440 AND (SYSDATE-1)- 15/1440 GROUP BY providerid ORDER BY providerid;
    W     450
    U     571
    T     80
    S     2
    I wnat output as like
    W     697 450
    U     813 571
    T     143 80
    S     2 2
    please help
    Thanks
    Praveen

    "COUNT", is that the real column name? It could become very confusing.
    Not tested for obvious reasons, but this should be close :
    SELECT providerid
         , sum(
             case when counttime between sysdate - 30/1440 and sysdate - 15/1440 then count end
           ) as cnt1
         , sum(
             case when counttime between (sysdate-1) - 30/1440 and (sysdate-1) - 15/1440 then count end
           ) as cnt2
    FROM appdev.usercounts
    WHERE ( counttime between sysdate - 30/1440 and sysdate - 15/1440 )
       OR ( counttime between (sysdate-1) - 30/1440 and (sysdate-1) - 15/1440 )
    GROUP BY providerid
    ORDER BY providerid
    ;

  • Check Sysdate for a specified Time

    Hi,
    I have requirement to check sysdate for particular time in a script,If it has systime is equal to that time in the evening, I need to exit the script and write messages to log file. I am doing the following but it's not working properly, Can anybody help with this?
    if sysdate > to_date('19:20','HH24:MI')then
    v_timeout := 'Y';
    v_output := 'Database Shutdown time... Exiting Script';
    utl_file.put_line(v_file_handle, v_output);
    Thanks
    Kalyan
    exit;
    end if;

    to_date('19:20','HH24:MI')The date out going by this command is the first day of the current month...
    SQL> select sysdate, to_date('19:20','HH24:MI') from dual;
    SYSDATE             TO_DATE('19:20','HH
    14-04-2008 13:19:42 01-04-2008 19:20:00You have to use the current day instead :
    SQL> select sysdate, trunc(sysdate)+19/24+20/1440 from dual;
    SYSDATE             TRUNC(SYSDATE)+19/2
    14-04-2008 13:21:21 14-04-2008 19:20:00Nicolas.
    Paolo, how did you made ? I have a opened window without your response above mine, and an other with your post... hmmm some strange forum behaviour...
    Message was edited by:
    N. Gasparotto

  • Using SYSDATE in RMAN script

    Hi
    Each night I move an RMAN backup from a PROD server to a test server.
    Then using RMAN script with NOCATALOG, I restore/recover the database on the test server as show below:
    RUN{
    ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
    STARTUP NOMOUNT;
    RESTORE CONTROLFILE from AUTOBACKUP;
    SHUTDOWN;
    STARTUP FORCE MOUNT;
    RESTORE DATABASE;
    RECOVER DATABASE;
    ALTER DATABASE OPEN RESETLOGS;
    Of course the script fails at the "RECOVER DATABASE" command because it runs out of ARCH logs to apply at some point and therefore never gets to the final command of DATABASE OPEN. I would like to change that line to something like:
    RECOVER DATABASE UNTIL TIME 'SYSDATE:02:45:00';
    The above fails with an RMAN error of "expected number".
    Of course I could use SET UNTIL TIME "to_date('SYSDATE 02:45:00','DD-MON-YYYY HH24:MI:SS')"; although I have the same problem, i.e., getting RMAN to accept SYSDATE as the date portion of the point in time recovery.
    Oddly, from an RMAN prompt and within brackets, I can issue the following command successfully:
    RMAN {
    set until time "to_date('SYSDATE 02:45:00','DD-MON-YYYY HH24:MI:SS')";
    command completed successfully
    So my question is, how can I use SYSDATE in an RMAN point in time recovery and have sysdate represent the current date, either in the RECOVER DATABASE line or the SET UNTIL TIME line?
    Thanks.

    user522620 wrote:
    Hi
    Each night I move an RMAN backup from a PROD server to a test server.
    Then using RMAN script with NOCATALOG, I restore/recover the database on the test server as show below:
    RUN{
    ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
    STARTUP NOMOUNT;
    RESTORE CONTROLFILE from AUTOBACKUP;
    SHUTDOWN;
    STARTUP FORCE MOUNT;
    RESTORE DATABASE;
    RECOVER DATABASE;
    ALTER DATABASE OPEN RESETLOGS;
    So my question is, how can I use SYSDATE in an RMAN point in time recovery and have sysdate represent the current date, either in the RECOVER DATABASE line or the SET UNTIL TIME line?
    Thanks.
    Given:
    SQL> alter session set NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS';
    SQL> select to_char(trunc(sysdate)+(2/24)+(45/1440),'dd-mon-yyyy hh24:mi') from
    dual;
    TO_CHAR(TRUNC(SYS
    25-JUN-2012 02:45:00
    Use this (uses to_date)
    RUN{
    set until time "to_date(trunc(sysdate)+(2/24)+(45/1440),'DD-MON-YYYY HH24:MI:SS')";
    ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
    STARTUP NOMOUNT;
    RESTORE CONTROLFILE from AUTOBACKUP;
    SHUTDOWN;
    STARTUP FORCE MOUNT;
    RESTORE DATABASE;
    RECOVER DATABASE;
    ALTER DATABASE OPEN RESETLOGS;
    ## if that command fails, it will fall to the next command as the run blocks are autonomous.
    RUN{
    ALTER DATABASE OPEN RESETLOGS;
    }

  • Fetch records under 20 seconds in my view with sysdate

    hi all
    I want a query in my view that it returns records under 20 seconds and
    after 20 seconds my query do not show any records
    my query is :
    select * from cnfenterexit
    where cnf06date > sysdate - (1/86400000)
    but it didn't work.
    when I used following query whit this numbers ,
    it is OK and show records under 56 seconds
    select * from cnfenterexit
    where cnf06date > sysdate - (3/1440)
    please explain how to get under 20 seconds in me query?

    or
    select *
      from cnfenterexit
    where cnf06date > sysdate -TO_DSINTERVAL('0 00:0:20')TO_DSINTERVAL('0 00:0:20') = 0 days, 0 hours, 0 minutes, 20 seconds
    Timo

  • 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'));

Maybe you are looking for

  • Is it normal for progress bar to appear at every start up ?

    after upgrading to Yosemite, every time i start my Mac a progress bar appears and it seems to take longer to get to the home screen - is this normal ?

  • Network Controller driver HP Notebook - 15-ac042tu

    Both WiFi and Bluetooth is not working Network controller is shown under unknown devices in device manager. Network ControllerPCI\VEN_14E4&DEV_4365&SUBSYS_804A103C&REV_01 PCI\VEN_14E4&DEV_4365&SUBSYS_804A103C PCI\VEN_14E4&DEV_4365&CC_028000 PCI\VEN_1

  • Mantain G/L Balance

    hi all, is there any way in sap through which we can mantain the G/L A/c Balance? i.e if an a/c balance goes below the particular balance the system should not allow the user to make any outgoing payment. I am an abap consultant.......so plz tell me

  • SQL Server Report services web part will cause lost page title

    Hello, I have a SSRS web part in my Sharepoint 2013 page, but I found the page title always lost after report load completed. I have checked the js code by debug, I found this is being caused by internal javascript executed by Sharepoint. The code as

  • Phoenix 1280 USB camera gives IMAQ USB Init error?

    We're trying to use a Phoenix PC-1280 USB video camera with either Labview or the Vision Assistant. In both cases we get an error in the IMAQ USB Init.vi (eg, "IVA Acquisiition Tools palette.vi was stopped at node 0x140 of subVI IMAQ USB Init.vi"). W