DD-MON-YY  to MM/DD/YYYY

Hi ,
I have data like '20080502' and it has to insert into a character field with the formart 'MM/DD/YYYY'
Right now using a statement like " select to_date(to_char('20080502'),'yyyy/mm/dd') from dual"
But, i got the output as 'DD-MON-YY'.
How to get a format ' MM/DD/YYYY' without changing NLS_DATE_FORMAT
Thanks

if your literal is in datatype of characters try converting them to date then bringing them back to charater datatype with the format you needed.
  SQL> select to_char(to_date('20080502','yyyymmdd'),'mm/dd/yyyy') new_dt
    2   from dual;
  NEW_DT
  05/02/2008
  SQL>

Similar Messages

  • Combining DD-MON field with YYYY field from GL table

    I am running into issues with GL_Cancelled_Date which is displaying the wrong 4 digit year. The GL_Encumbered_Date for these rows is correct and I am looking at ways to combine these fields to output the correct full DD-MON-YYYY date. The below code displays all of the bad rows of data and the last two coloumns display the correct DD-MON and YYYY dates. But I am unsure of how to combine the DD-MON from GL_Cancelled_Date with the YYYY from GL_Encumbered_Date.
    I have written out:
    SELECT
          PRH.SEGMENT1,
          prd.GL_ENCUMBERED_DATE,
          TO_CHAR(PRD.GL_ENCUMBERED_DATE,'YYYY'),
          PRD.GL_CANCELLED_DATE,
          TO_CHAR(PRD.GL_CANCELLED_DATE, 'DD-MON-YYYY'),
          to_char(prd.gl_cancelled_date,'YYYY'),
          to_char(prd.gl_cancelled_date,'DD-MON-') as date_day_month,
          to_char(prd.gl_encumbered_date,'YYYY') as date_year
    FROM
         PO_REQUISITION_HEADERS_ALL PRH,
         PO_REQUISITION_LINES_ALL   PRL,
         PO_REQ_DISTRIBUTIONS_ALL   PRD
    WHERE
         PRH.REQUISITION_HEADER_ID = PRL.REQUISITION_HEADER_ID
          AND   PRL.REQUISITION_LINE_ID   = PRD.REQUISITION_LINE_ID
          AND   PRD.GL_CANCELLED_DATE IS NOT NULL
          AND   to_char(PRD.GL_CANCELLED_DATE,'YYYY') LIKE '00%';

    Hi,
    Here's one way to correct the table:
    UPDATE  po_req_distributions_all
    SET     gl_cancelled_date = ADD_MONTHS ( gl_cancelled_date
                                           , 12 * ( EXTRACT (YEAR FROM gl_encumbered_date)
                                                  - EXTRACT (YEAR FROM gl_cancelled_date)
    WHERE   EXTRACT (YEAR FROM gl_encumbered_date)
        <>  EXTRACT (YEAR FROM gl_cancelled_date)
    When this finishes, gl_cancelled_date will always have the same year as gl_encumbered_date, but hte original months, days, hours, minutes and seconds of gl_cancelled_date will be unchanged.  (Exception: If the original gl_cancelled_date is February 29, and gl_encumbered_date is NOT in a leap year, then the day will be changed to 28, since there is no February 29 in the correct year.  If the original gl_cancelled_date is February 28, and gl_encumbered_date IS in a leap year, then the day will be changed to 29.  This can be fixed if it's a problem.)
    I hope this answers your question.
    If not, post  a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    If you're asking about a DML statement, such as UPDATE, the sample data will be the contents of the table(s) before the DML, and the results will be state of the changed table(s) when everything is finished.
    Point out where the statement above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How can I deal with 19YY vs 20YY problem?

    Hi,
    I have a sqlldr control file that looks something like this ...
    LOAD DATA
    INFILE *
    REPLACE INTO TABLE BLAH_BLAH_BLAH
    FIELDS TERMINATED BY '|' TRAILING NULLCOLS
    COL1,
    THE_DATE,
    COL2
    BEGINDATA
    ABC|01-JAN-82|BLAHBLAH
    XYZ|01-AUG-00|BLAHBLAH
    where 01-JAN-82 is intended to be January 1st 1982
    and 01-AUG-82 is intended to be August 1st 2000
    But when I do this ...
    select to_char( THE_DATE, 'YYYYMMDD' ) from BLAH_BLAH where COL1 in ( 'ABC', 'XYZ' );
    ... I get this ...
    TO_CHAR(
    20820101
    20000801
    The thing that bugs me is that when I do this ...
    select to_char( to_date( '01-AUG-82'), 'YYYYMMDD' ) from dual;
    ... I get ...
    TO_CHAR(
    19820801
    ... Can anyone give me a hand?

    If the standard Oracle format was used (DD-MON-YY) then the following has occured :
    01-JAN-42 has gone in as 01-JAN-2042
    01-JAN-49 has gone in as 01-JAN-2049
    01-JAN-50 has gone in as 01-JAN-2050
    01-JAN-62 has gone in as 01-JAN-2062
    01-JAN-82 has gone in as 01-JAN-2082
    01-JAN-02 has gone in as 01-JAN-2002
    01-JAN-22 has gone in as 01-JAN-2022
    If you had used a mask like DD-MON-RR in your loader script the following would have occured :
    01-JAN-42 has gone in as 01-JAN-2042
    01-JAN-49 has gone in as 01-JAN-2049
    01-JAN-50 has gone in as 01-JAN-1950
    01-JAN-62 has gone in as 01-JAN-1962
    01-JAN-82 has gone in as 01-JAN-1982
    01-JAN-02 has gone in as 01-JAN-2002
    01-JAN-22 has gone in as 01-JAN-2022
    See http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/sql_elements4a.htm#35239 and search for "The RR Date Format Element"
    So you currently have some incorrect dates in your table :
    01-JAN-42 has gone in as 01-JAN-2042 CORRECT
    01-JAN-49 has gone in as 01-JAN-2049 CORRECT
    01-JAN-50 has gone in as 01-JAN-2050 INCORRECT
    01-JAN-62 has gone in as 01-JAN-2062 INCORRECT
    01-JAN-82 has gone in as 01-JAN-2082 INCORRECT
    01-JAN-02 has gone in as 01-JAN-2002 CORRECT
    01-JAN-22 has gone in as 01-JAN-2022 CORRECT
    So you need to (a) identify incorrect dates and (b) amend incorrect dates
    update TABLE_BLAH
    set DOB = to_date(to_char(DOB,'DD-MON-')||to_char(to_number(to_char(DOB,'YYYY'))-100), 'DD-MON-YYYY');
    where to_number(to_char(DOB, 'YYYY')) > 2049
    Please note I have not checked for typos
    AMM

  • I can't see the error here

    I'm getting the error 'Column not allowed here'.
    Here's the code and description of resulting table:
    CREATE OR REPLACE PROCEDURE prod_sales_sum_sp
    IS
    CURSOR cur_sales
    IS
      SELECT bi.idproduct id,
        TO_CHAR(b.dtordered,'MON') mth,
        TO_CHAR(b.dtordered, 'YYYY') yr,
        SUM(bi.quantity) quantity,
        SUM(bi.quantity*bi.price) totalsum
         FROM bb_basket b INNER JOIN bb_basketitem bi
         USING (idbasket)
         WHERE b.orderplaced = 1
         GROUP BY bi.idproduct,TO_CHAR(b.dtordered,'MON'),TO_CHAR(b.dtordered, 'YYYY');
    BEGIN
    FOR rec_sales IN cur_sales LOOP
      INSERT INTO bb_prod_sales (idproduct, month, year, qty, total)
      VALUES (id, mth, yr, quantity, totalsum);
    END LOOP;
    END;
    SQL> desc bb_prod_sales
    Name                                                  Null?    Type
    IDPRODUCT                                                      NUMBER(2)
    MONTH                                                          CHAR(3)
    YEAR                                                           CHAR(4)
    QTY                                                            NUMBER(5)
    TOTAL                                                          NUMBER(6,2)
    SQL> select * from bb_prod_sales;
    no rows selectedBasically, we see that the table has five columns: idproduct, month, year, qty, and total. It also has no values at this point in time.
    I'm trying to create this procedure to update the table by inserting values into the table.
    With the error being provided, isn't that basically saying I'm using a column name while I'm trying to insert my values? I've set alias names so there are no conflicts, and it's still giving me the error.
    Can you guys see anythign?

    Hi,
    The way to reference columns in a record is record_name.column_name, so you should say:
    VALUES (rec_sales.id, rec_sales.mth, rec_sales.yr, rec_sales.quantity, rec_sales.totalsum);

  • SQL expression in ODI

    I Have the following interface in oracle data integrator
    http://i44.tinypic.com/2mrsmxt.png
    # it execute successfully before inserting the following expression 
      In the mapping I insert the following SQL expression to get the average when the quantity is 0
    AVG(
    CASE WHEN TEST.QUN = 0 THEN
    (SELECT TEST.QUN FROM TEST
    WHERE TEST1.PRUDU=TEST.PRUDU
    AND TEST1.FLOW=TEST.UNIT
    AND TEST1.UNIT=TEST.UNIT
    AND to_char(TEST.DATEDDD,'MON')= to_char(TEST1.DATEDDD,'MON')
    AND TEST1.DATEDDD !=TEST.DATEDDD
    GROUP BY TEST.QUN
    ELSE TEST.QUN
    END)
    when I check this expression in ODI ..
    # the sql expression is correct for this  RDMS 
    when I executed the interface i get this error
    Caused By: java.sql.SQLSyntaxErrorException: ORA-00937: not a single-group group function
    any idea ?

    I changed the code a little ..
    CASE WHEN TEST.QUN = 0 THEN
    (SELECT AVG(TEST.QUN) FROM TEST
    WHERE TEST1.PRUDU=TEST.PRUDU
    AND TEST1.FLOW=TEST.FLOW
    AND TEST1.UNIT=TEST.UNIT
    AND to_char(TEST.DATEDDD,'MON')= to_char(TEST1.DATEDDD,'MON')
    AND to_char(TEST.DATEDDD,'YYYY')!= to_char(TEST1.DATEDDD,'YYYY')
    ELSE TEST.QUN
    END
    And I get this error ..
    ORA-01427: single-row subquery returns more than one row tips.
    The TEST Table from the source and TEST1 is a lookup table because I couldn't  do the alais in ODI
    In sql developer I did the following code that will do the same thing and work successfully ..
    update test B
    set B.qun=
    (SELECT AVG(TEST.QUN) FROM TEST
    WHERE  TEST.FLOW=B.UNIT
    AND TEST.UNIT=B.UNIT
    AND TEST.PRUDU=b.prudu
    AND TEST.FLOW=b.flow
    AND to_char(TEST.DATEDDD,'MON')= to_char(B.DATEDDD,'MON')
    AND to_char(TEST.DATEDDD,'YYYY')!= to_char(B.DATEDDD,'YYYY')
    where B.qun=0;
    any help ?
    thanksssss
    naif ..

  • Parse file text file

    Hi,
    I like read Apache error log using external table.
    For this I did create directory APACHE_LOG and grant read permission to it for my schema.
    Then external table
    CREATE TABLE EXT_APACHE_ERROR_LOG
        "TEXT" VARCHAR2(2000 BYTE)
      ORGANIZATION EXTERNAL
        TYPE ORACLE_LOADER DEFAULT DIRECTORY "APACHE_LOG" ACCESS PARAMETERS ( records delimited BY newline nobadfile nodiscardfile nologfile ) LOCATION ( "APACHE_LOG":'error.log' )
      REJECT LIMIT UNLIMITED;Log format is like below
    [Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] client denied by server configuration: /export/home/live/ap/htdocs/testI have try read file using query
    SELECT REGEXP_SUBSTR(text, '[^\[]+(.*?)')      AS mesg_date,
      REGEXP_SUBSTR(text, '\[([a-z]*?)\]')         AS mesg_type,
      REGEXP_SUBSTR(text, '\[client ([0-9\.]*)\]') AS client,
      REGEXP_SUBSTR(text, '\] (.*)$')              AS mesg
    FROM ext_apache_error_log;Output it is not quite what I like have as I'm bad with regexp.
    I like have result in 4 columns like
    MESG_DATE               MESG_TYPE     CLIENT          MESG
    Wed Oct 11 14:32:52 2000     error          127.0.01     client denied by server configuration: /export/home/live/ap/htdocs/testSo I need bit help
    What is best method parse that log format?
    Can I have those 4 columns some way already to external table?
    Thanks advance
    Regards,
    Jari

    Hi,
    I just noticed that log have lines where is no data for third column (client).
    This query demonstrate situation
    WITH test_data AS
      (SELECT '[Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] client denied by server configuration: /export/home/live/ap/htdocs/test' text
      FROM dual
      UNION ALL
      SELECT '[Wed Oct 11 14:32:52 2000] [notice] SIGUSR1 received.  Doing graceful restart' text
      FROM dual
    SELECT REGEXP_replace(text, '^\[(.*?)\].*$', '\1')   AS mesg_date,
      REGEXP_SUBSTR(text, '\[(.*?)\]',1,2)               AS mesg_type,
      REGEXP_SUBSTR(text, '\[(.*?)\]',1,3)               AS client,
      REGEXP_replace(text, '^(\[.*?\]\s){3}(.*)$', '\2') AS mesg
    FROM test_data ;In case there is no client info whole line from file is in fourth column (mesg).
    What could be best way handle this case so that client column is null but only the message should shown in mesg column ?
    Thanks advance
    Regards,
    Jari
    Edited by: jarola on Aug 31, 2011 8:24 PM
    I did come to this query
    WITH test_data AS
      (SELECT '[Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] client denied by server configuration: /export/home/live/ap/htdocs/test' text
      FROM dual
      UNION ALL
      SELECT '[Wed Oct 11 14:32:52 2000] [notice] SIGUSR1 received.  Doing graceful restart' text
      FROM dual
    SELECT TO_DATE(REGEXP_REPLACE(text, '^\[(.*?)\].*$', '\1'),'Dy Mon DD HH24:MI:SS YYYY', 'NLS_DATE_LANGUAGE = AMERICAN') AS mesg_date,
      REGEXP_SUBSTR(text, '\[(.*?)\]',1,2)                                                                                  AS mesg_type,
      REGEXP_SUBSTR(text, '\[(.*?)\]',1,3)                                                                                  AS client,
      REGEXP_REPLACE(REGEXP_REPLACE(text, '^(\[.*?\]\s){3}(.*)$','\2'), '^(\[.*?\]\s){2}(.*)$','\2')                        AS mesg
    FROM test_data ;It seems work. If somebody have better query please post.
    And also if there is in good way combine expression that remove opening bracket and closing bracket from MESG_TYPE and CLIENT columns.
    Thanks

  • NLS_DATE_FORMAT in NLS_SESSION_PARAMETERS and USERENV is different

    I have got two databases which were created by two different DBA teams.
    When I run a package it ran successfully on ORASID1 but failed on ORASID2 with ORA-01861: literal does not match format string. I've found that the query in question is trying to apply a TO_DATE() function on a DATE type column.
    Now, my question is: Why the same code didnot fail on SID1.
    When I compared the NLS_DATABASE_PARAMETERS, NLS_INSTANCE_PARAMETERS, NLS_SESSION_PARAMETERS, then I did not find any difference.
    But, when I checked the NLS parameters using the below query, I found that the NLS_DATE_FORMAT is different.
    Note: I checked all the aforesaid settings from sqlplus prompt on the Unix box.
    SELECT
    SYS_CONTEXT('USERENV','NLS_TERRITORY') nls_territory,
    SYS_CONTEXT('USERENV','NLS_DATE_FORMAT') nls_date_format,
    SYS_CONTEXT('USERENV','NLS_DATE_LANGUAGE') nls_date_language,
    SYS_CONTEXT('USERENV','NLS_SORT') nls_sort,
    SYS_CONTEXT('USERENV','LANGUAGE') language
    FROM DUAL;
    ORASID1 NLS Settings:
    NLS Territory:AMERICA
    NLS Currency:$
    NLS Date Format:DD-MON-RR
    NLS Date Language:AMERICAN
    NLS Sort:BINARY
    Language:AMERICAN_AMERICA.UTF8
    ORASID2 NLS Settings:
    NLS Territory:AMERICA
    NLS Currency:$
    NLS Date Format:YYYY-MM-DD HH24:MI:SS
    NLS Date Language:AMERICAN
    NLS Sort:BINARY
    Language:AMERICAN_AMERICA.UTF8
    Could someone please explain how come the values in nls_session_parameters table are same but when the same value is checked from userenv it shows different results for NLS_DATE_FORMAT?
    Thanks in advance.

    To be precise, the result of your query was something like this:
    ON ORASID1:
    AMERICAN === DD-MON-RR
    AMERICA === DD-MON-RR
    $ === DD-MON-RR
    AMERICA === DD-MON-RR
    ., === DD-MON-RR
    GREGORIAN === DD-MON-RR
    DD-MON-RR === DD-MON-RR
    AMERICAN === DD-MON-RR
    BINARY ==== DD-MON-RR
    HH.MI.SSXFF AM === DD-MON-RR
    DD-MON-RR HH.MI.SSXFF AM === DD-MON-RR
    HH.MI.SSXFF AM TZR === DD-MON-RR
    DD-MON-RR HH.MI.SSXFF AM TZR === DD-MON-RR
    $ === DD-MON-RR
    BINARY === DD-MON-RR
    BYTE === DD-MON-RR
    FALSE === DD-MON-RR
    ON ORASID2:
    AMERICAN === YYYY-MM-DD HH24:MI:SS
    AMERICA === YYYY-MM-DD HH24:MI:SS
    $ === YYYY-MM-DD HH24:MI:SS
    AMERICA === YYYY-MM-DD HH24:MI:SS
    ., === YYYY-MM-DD HH24:MI:SS
    GREGORIAN === YYYY-MM-DD HH24:MI:SS
    YYYY-MM-DD HH24:MI:SS === YYYY-MM-DD HH24:MI:SS
    AMERICAN === YYYY-MM-DD HH24:MI:SS
    BINARY === YYYY-MM-DD HH24:MI:SS
    HH.MI.SSXFF AM === YYYY-MM-DD HH24:MI:SS
    DD-MON-RR HH.MI.SSXFF AM === YYYY-MM-DD HH24:MI:SS
    HH.MI.SSXFF AM TZR === YYYY-MM-DD HH24:MI:SS
    DD-MON-RR HH.MI.SSXFF AM TZR === YYYY-MM-DD HH24:MI:SS
    $ === YYYY-MM-DD HH24:MI:SS
    BINARY === YYYY-MM-DD HH24:MI:SS
    BYTE === YYYY-MM-DD HH24:MI:SS
    FALSE === YYYY-MM-DD HH24:MI:SS

  • Error: ORA-01012: not logged on

    Hi all,
    i have a program to update 2 tables and will commit every transaction for each table. firstly, my program will commit transaction in Table A then once it's done, it will commit Table B and loop again(both table) until all transactions finish.But at the end of the process, i get the error msg:
    Error: ORA-01012: not logged on
    I suspected this error because of COMMIT issue in my program.
    Kindly need someone to assist me.
    Here i attached my code for your reference.
    EXEC SQL DECLARE fs_cursor CURSOR FOR SELECT fs.FILE_ID FROM FILE_STATUS fs
    where fs.JOB_ID = 'brm_pymntd01l' and fs.status = 'N'
    FOR UPDATE OF fs.STATUS;
    EXEC SQL OPEN fs_cursor;
    EXEC SQL WHENEVER NOT FOUND DO break;
    for (;;)
    rec_ctr = 0;
    /** Reset the sqlcode **/
    sqlca.sqlcode=0;
    EXEC SQL FETCH fs_cursor INTO :FILEID;
    EXEC SQL DECLARE ft_cursor CURSOR FOR SELECT FT.RECORD_ID FROM FILE_DETAIL FT WHERE FT.STATUS = 'N' AND FT.FILE_ID = :FILEID;
              EXEC SQL OPEN ft_cursor;
    EXEC SQL WHENEVER NOT FOUND DO break;           
    if ( sqlca.sqlcode == 0)
    for (;;)
                   EXEC SQL FETCH ft_cursor INTO :RECORD_ID;
    EXEC SQL DECLARE fd_cursor ...
    FROM FILE_DETAIL fd where fd.RECORD_ID = :RECORD_ID and fd.file_id = :FILEID FOR UPDATE OF fd.STATUS;
    EXEC SQL OPEN fd_cursor;
    /** Reset the sqlcode **/
    sqlca.sqlcode=0;
    EXEC SQL FETCH fd_cursor INTO :COL1, :COL2, :COL3, :COL4, :COL5, :COL6, :COL7, :COL8, :COL9,
    :COL10, :COL11, :COL13, :COL14, :COL15,
    :COL16, :COL19, :COL20, :COL21, :COL22, :COL24, :COL25, :COL26, :COL27, :STATUS;
    if (validate_record(dbschema,logfp,&ebuf))
    trim_spaces();
    process_flag = process(ctxp, database, &ebuf, logfp, dbschema);
    time(&status_upd_date);
    strcpy(current_time, ctime(&status_upd_date));
    if(process_flag == PROCESS_SUCCESS)
    if (updateChargeEvent == 1) {
    PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_DEBUG, "*******Update Charge Event\0");
    ret = update_charge_event(ctxp, database, &ebuf, ACCOUNT_NO, PAYMENT_DATE);
    if(ret != 1)
    strcpy(NEW_STATUS, "P");
    sprintf(msg,"Transaction [PUKAL update status] error. Please check cm.pinlog.");
    strcpy(REC_ERROR_CODE, ERR_GET_UPD_PUKAL_EVENT);
    strcpy(REC_ERROR_DESCR,msg);
    log(msg, logfp);
    log("\n",logfp);
    }else{
    strcpy(NEW_STATUS, "C");
    strcpy(NEXT_BILL_T, NEXT_BILL_DATE);
    else if (rebateSucess != 0)
    strcpy(NEW_STATUS, "P");
    sprintf(msg,"Transaction [apply_rebate] error. Please check cm.pinlog.");
    strcpy(REC_ERROR_CODE, ERR_GET_APPLY_REBATE);
    strcpy(REC_ERROR_DESCR,msg);
    log(msg, logfp);
    log("\n",logfp);
    else {
    strcpy(NEXT_BILL_T, NEXT_BILL_DATE);
    strcpy(NEW_STATUS, "C");
    EXEC SQL UPDATE FILE_DETAIL
    SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY'),
    COL23 = :NEXT_BILL_DATE,
    COL27 = :COLUMN_27
    WHERE RECORD_ID = :RECORD_ID;
    else
    strcpy(NEW_STATUS, "F");
    EXEC SQL UPDATE FILE_DETAIL
    SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY'),
    ERROR_CODE = :REC_ERROR_CODE,
    ERROR_DESC = :REC_ERROR_DESCR
    WHERE RECORD_ID = :RECORD_ID;
    ret = JOB_WARNING;
    else
    strcpy(NEW_STATUS, "F");
    EXEC SQL UPDATE FILE_DETAIL
    SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY'),
    ERROR_CODE = :REC_ERROR_CODE,
    ERROR_DESC = :REC_ERROR_DESCR
    WHERE RECORD_ID = :RECORD_ID;
    ret = JOB_WARNING;
    else{   
    PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_DEBUG, "Error running query");
    printf("\nError: %.70s \n",sqlca.sqlerrm.sqlerrmc);
    EXEC SQL CLOSE fd_cursor;
         EXEC SQL COMMIT;
         rec_ctr ++;
         EXEC SQL CLOSE ft_cursor;
    time(&status_upd_date);
    strcpy(current_time, ctime(&status_upd_date));
    if (rec_ctr > 0)
    /* Check if all records had failed, one record had failed
    or everything is successfully processed. Then update
    file_status table. */
    int ret_status;
    ret_status = updateFileStatus(dbschema, FILEID, logfp);
    if (ret_status == ALL_REC_FAILED)
    strcpy(NEW_STATUS, "F");
    EXEC SQL UPDATE FILE_STATUS SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY')
    WHERE CURRENT OF fs_cursor;
    else if (ret_status == ONE_REC_FAILED)
    strcpy(NEW_STATUS, "P");
    EXEC SQL UPDATE FILE_STATUS SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY')
    WHERE CURRENT OF fs_cursor;
    else if (ret_status == ALL_SUCCESS)
    strcpy(NEW_STATUS, "C");
    EXEC SQL UPDATE FILE_STATUS SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY')
    WHERE CURRENT OF fs_cursor;
    /* Else do nothing error handling is done within
    * the function. */
    else{}
    else{
    /*If its an empty file, update file_status to 'C'
    so that the program will no longer fetch this record
    on the next run. */
    strcpy(NEW_STATUS, "C");
    EXEC SQL UPDATE FILE_STATUS SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY')
    WHERE CURRENT OF fs_cursor;
         EXEC SQL COMMIT WORK RELEASE;
    //process by not update by per transaction at staging
         EXEC SQL CLOSE fs_cursor;
    if(sqlca.sqlcode == 0)
    ret = JOB_SUCCESS;
    else
    EXEC SQL ROLLBACK WORK RELEASE;
    Thank a lots!

    what data did not get COMMITted?

  • Query:how to get older date and value

    Hi,
    I am trying to develop a query that gives me the current amount assigned to a user/employee and the previous amount/old amount assigned to the employee.
    The query so far looks like this:
    select distinct p.ELEMENT_ENTRY_ID
    +,p.EFFECTIVE_START_DATE+
    +,p.EFFECTIVE_END_DATE+
    +,p.LAST_UPDATE_DATE "UPDATE DATE"+
    +,to_char(p.LAST_UPDATE_DATE,'MON') MONTH+
    +,to_char(p.LAST_UPDATE_DATE,'YYYY') YEAR+
    +,p.LAST_UPDATED_BY+
    +,u.USER_NAME "ENTERED BY USERNAME"+
    +,e1.FULL_NAME "ENTERED BY "+
    +,v.EFFECTIVE_START_DATE+
    +,v.EFFECTIVE_END_DATE+
    +,v.SCREEN_ENTRY_VALUE "NEW AMOUNT"+
    +,t.ELEMENT_TYPE_ID+
    +,t.INPUT_CURRENCY_CODE "AMOUNT CURRENCY",t.ELEMENT_NAME+
    +,t.DESCRIPTION+
    +,e.FULL_NAME "ASSIGNED TO"+
    from
    pay_element_entries_f       p
    +,PAY_ELEMENT_ENTRY_VALUES_F v+
    +,pay_element_types_f t+
    +,PER_ALL_ASSIGNMENTS_F a+
    +,per_all_people_f e+
    +,fnd_user u+
    +,per_all_people_f e1+
    where
    p.ELEMENT_ENTRY_ID=v.ELEMENT_ENTRY_ID
    and p.EFFECTIVE_END_DATE=v.EFFECTIVE_END_DATE
    and t.ELEMENT_TYPE_ID=p.ELEMENT_TYPE_ID
    and t.BUSINESS_GROUP_ID=229
    and a.ASSIGNMENT_ID=p.ASSIGNMENT_ID
    and e.PERSON_ID=a.PERSON_ID
    and p.LAST_UPDATED_BY=u.USER_ID
    and v.SCREEN_ENTRY_VALUE <>'NULL'
    and u.PERSON_PARTY_ID=e1.PARTY_ID()+
    and p.CREATOR_TYPE <> 'F'
    and e.EFFECTIVE_END_DATE> sysdate
    and p.CREATOR_TYPE='SP'
    and p.EFFECTIVE_END_DATE>sysdate
    I need the older value of v.SCREEN_ENTRY_VALUE and the ,*v.EFFECTIVE_START_DATE*
    *,v.EFFECTIVE_END_DATE* columns may vary from one employee to another and there could be more than two older values for each employee.
    Any suggesions please.....

    AHS wrote:
    Any suggesions please.....Yes.
    1) post your Oracle version
    select * from v$version;2) post some create table DDL and sample data (in the form of insert statements) so we have an idea of what you're starting with (this would be after you come up with a small, but complete example of your problem)
    3) show us sample output representing the correct results based on the data in step # the second.
    4) format your code with the tags                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • 1st pay of the year hours double ?

    Hi,
    This is my situation (happened in 2007, 2008)
    Ex: For the 1st pay of 2008 I have this pay period (Dec 30, 2007 to Jan 12, 2008) payable on January 10, 2008
    On my RT table :
    Regular    $20.00    64 hours   $228.58
    Regular    $20.00    64 hours   $1,371.42
    Stat hol    $20.00    3.43 hours $68.60
    Stat hol    $20.00   20.57 hours $411.40
    My problem with this :
    1 - For stat holiday it all ok because the total hours = 24 hours BUT for regular hours I should have 64 hours total and not two time 64 hours (note the amount are good )
    2 - When I try to re-create this situation with simulation or a sand box I always have the right thing it look impossible to re-create this error but I know when it will be the 1st pay of 2009 I will have again the same problem with hours ?
    Can you help me ?
    Thank you,
    Jean

    select t.v_id, to_char(t.close_date, 'YYYY-MM-DD')
      from table_one t
    where t.close_date between to_date('2010/1/1', 'YYYY-MM-DD') and to_date('2010/12/31', 'YYYY-MM-DD')
    and   to_char(trunc (t.close_date), 'dy' ) = 'mon'
    V_ID     TO_CHAR(T.CLOSE_DATE,'YYYY-MM-DD')
    B     2010-01-04
    C     2010-01-11
    E     2010-05-03if you also want the first day of the year included as you mentioned.
    select t.v_id, to_char(t.close_date, 'YYYY-MM-DD')
      from table_one t
    where t.close_date between to_date('2010/1/1', 'YYYY-MM-DD') and to_date('2010/12/31', 'YYYY-MM-DD')
    and   to_char(trunc (t.close_date), 'dy' ) = 'mon'
    or  extract( month from t.close_date) + extract( day from t.close_date) = 2
    V_ID     TO_CHAR(T.CLOSE_DATE,'YYYY-MM-DD')
    A     2010-01-01
    B     2010-01-04
    C     2010-01-11
    E     2010-05-03Edited by: pollywog on Nov 17, 2010 11:38 AM

  • Checking correct data format using sql query

    1) I got column date of joining which accepts date in below format
    DD-MON-YYYY
    DD-MON-YY
    MON-DD-YYYY
    MON-DD-YY
    Month DD,YYYY
    Question:- how do i check whether all dates in Date of joining column are in above format or not using sql query?
    2) I got one more date column which accepts date in below format
    MMDDYYYY
    YYYYMMDD
    MM/DD/YYYY
    MM/DD/YY
    YYYY/DD/MM
    Question:- how do i check whether all dates in date column are in above format or not using sql query?
    sorry if it is a very simple question since I am new to sql and trying to learn ......Thanks for the answers from the group............

    In short, NO, it's not possible.  If you store dates correctly in the database as DATE datatype then you don't have this problem.  If you store them as VARCHAR2 you have a problem.
    So, you get a date of 20092012
    Is that 20th September 2012?  or is it 20th December 2009?
    What about...
    11-Jan-12
    Is that 11th January 2012 or 12th January 2011?
    Dates should never be stored on the database as strings.  That is why Oracle gives you a DATE datatype so you can store them properly.
    Also, when dates are passed from an application to the database, the application should be passing them as DATE datatype, and the application interface should be designed to accept dates from the user in a format specific to their country/locality and it would then know what that format is and automatically convert it to a DATE datatype before it gets anywhere near the database or any SQL.

  • SQL Loader Inserting Log File Statistics to a table

    Hello.
    I'm contemplating how to approach gathering the statistics from the SQL Loader log file to insert them into a table. I've approached this from a Korn Shell Script perspective previously, but now that I'm working in a Windows environment and my peers aren't keen about batch files and scripting I thought I'd attempt to use SQL Loader itself to read the log file and insert one or more records into a table that tracks data uploads. Has anyone created a control file that accomplishes this?
    My current environment:
    Windows 2003 Server
    SQL*Loader: Release 10.2.0.1.0
    Thanks,
    Luke

    Hello.
    Learned a little about inserting into multiple tables with delimited records. Here is my current tested control file:
    LOAD DATA
    APPEND
    INTO TABLE upload_log
    WHEN (1:12) = 'SQL*Loader: '
    FIELDS TERMINATED BY WHITESPACE
    TRAILING NULLCOLS
    (  upload_log_id   RECNUM
    , filler_field_0  FILLER
    , filler_field_1  FILLER
    , filler_field_2  FILLER
    , filler_field_3  FILLER
    , filler_field_4  FILLER
    , filler_field_5  FILLER
    , day_of_week
    , month
    , day_of_month
    , time_of_day
    , year
    , log_started_on          "TO_DATE((:month ||' '|| :day_of_month ||' '|| :time_of_day ||' '|| :year), 'Mon DD HH24:MI:SS YYYY')"
    INTO TABLE upload_log
    WHEN (1:11) = 'Data File: '
    FIELDS TERMINATED BY ':'
    (  upload_log_id    RECNUM
    , filler_field_0   FILLER  POSITION(1)
    , input_file_name          "TRIM(:input_file_name)"
    INTO TABLE upload_log
    WHEN (1:6) = 'Table '
    FIELDS TERMINATED BY WHITESPACE
    (  upload_log_id   RECNUM
    , filler_field_0  FILLER  POSITION(1)
    , table_name              "RTRIM(:table_name, ',')"
    INTO TABLE upload_rejects
    WHEN (1:7) = 'Record '
    FIELDS TERMINATED BY ':'
    (  upload_rejects_id  RECNUM
    , record_number      POSITION(1)  "TO_NUMBER(SUBSTR(:record_number,8,20))"
    , reason
    INTO TABLE upload_rejects
    WHEN (1:4) = 'ORA-'
    FIELDS TERMINATED BY ':'
    (  upload_rejects_id  RECNUM
    , error_code         POSITION(1)
    , error_desc
    INTO TABLE upload_log
    WHEN (1:22) = 'Total logical records '
    FIELDS TERMINATED BY WHITESPACE
    (  upload_log_id      RECNUM
    , filler_field_0     FILLER  POSITION(1)
    , filler_field_1     FILLER
    , filler_field_2     FILLER
    , action                     "RTRIM(:action, ':')"
    , number_of_records
    INTO TABLE upload_log
    WHEN (1:13) = 'Run began on '
    FIELDS TERMINATED BY WHITESPACE
    TRAILING NULLCOLS
    (  upload_log_id   RECNUM
    , filler_field_0  FILLER  POSITION(1)
    , filler_field_1  FILLER
    , filler_field_2  FILLER
    , day_of_week
    , month
    , day_of_month
    , time_of_day
    , year
    , run_began_on            "TO_DATE((:month ||' '|| :day_of_month ||' '|| :time_of_day ||' '|| :year), 'Mon DD HH24:MI:SS YYYY')"
    INTO TABLE upload_log
    WHEN (1:13) = 'Run ended on '
    FIELDS TERMINATED BY WHITESPACE
    TRAILING NULLCOLS
    (  upload_log_id   RECNUM
    , filler_field_0  FILLER  POSITION(1)
    , filler_field_1  FILLER
    , filler_field_2  FILLER
    , day_of_week
    , month
    , day_of_month
    , time_of_day
    , year
    , run_ended_on            "TO_DATE((:month ||' '|| :day_of_month ||' '|| :time_of_day ||' '|| :year), 'Mon DD HH24:MI:SS YYYY')"
    INTO TABLE upload_log
    WHEN (1:18) = 'Elapsed time was: '
    FIELDS TERMINATED BY ':'
    (  upload_log_id   RECNUM
    , filler_field_0  FILLER  POSITION(1)
    , filler_field_1  FILLER
    , filler_field_2  FILLER
    , elapsed_time
    INTO TABLE upload_log
    WHEN (1:14) = 'CPU time was: '
    FIELDS TERMINATED BY ':'
    (  upload_log_id   RECNUM
    , filler_field_0  FILLER  POSITION(1)
    , filler_field_1  FILLER
    , filler_field_2  FILLER
    , cpu_time
    )Here are the basic table create scripts:
    TRUNCATE TABLE upload_log;
    DROP TABLE upload_log;
    CREATE TABLE upload_log
    (  upload_log_id      INTEGER
    , day_of_week        VARCHAR2(  3)
    , month              VARCHAR2(  3)
    , day_of_month       INTEGER
    , time_of_day        VARCHAR2(  8)
    , year               INTEGER
    , log_started_on     DATE
    , input_file_name    VARCHAR2(255)
    , table_name         VARCHAR2( 30)
    , action             VARCHAR2( 10)
    , number_of_records  INTEGER
    , run_began_on       DATE
    , run_ended_on       DATE
    , elapsed_time       VARCHAR2(  8)
    , cpu_time           VARCHAR2(  8)
    TRUNCATE TABLE upload_rejects;
    DROP TABLE upload_rejects;
    CREATE TABLE upload_rejects
    (  upload_rejects_id  INTEGER
    , record_number      INTEGER
    , reason             VARCHAR2(255)
    , error_code         VARCHAR2(  9)
    , error_desc         VARCHAR2(255)
    );Now, if I could only insert a single record to the upload_log table (per table logged); adding separate columns for skipped, read, rejected, discarded quantities. Any advice on how to use SQL Loader to do this (writing a procedure would be fairly simple, but I'd like to perform all of the work in one place if at all possible)?
    Thanks,
    Luke
    Edited by: Luke Mackey on Nov 12, 2009 4:28 PM

  • Csv input adapter - read rows with different # of columns

    I have a csv file which includes rows with different number of columns. I want to read all the rows( of different # of cols)  into ONE stream only and then split into separate streams afterwards.
    I saw that CSV File Input Adapter does not add missing columns with nulls by default. Is it possible somehow? How can I generate a workaround?
    Thanks.

    Hello,
    The CSV Input Adapter expects to find a fixed number of fields.  If you attach the input adapter to a stream/window with 3 fields, it will always try to read three fields.  You can have missing data and this will be read into a column as a NULL value but the delimiters must still be there.  For example:
    1,1,1
    2,2,2
    3,3,3
    4,,4
    5,5,5
    CREATE INPUT WINDOW inWindow SCHEMA (c1 integer, c2 integer, c3 integer) PRIMARY KEY (c1);
    ATTACH INPUT ADAPTER File_Hadoop_CSV_Input2 TYPE toolkit_file_csv_input TO inWindow PROPERTIES csvExpectStreamNameOpcode = FALSE ,
      dir = 'c:/temp' ,
      file = 'test.csv' ,
      csvDelimiter = ',' ;
    A workaround you might consider is reading an entire line from your file into a stream with a single string column.  The trick is that you have to choose a character for the column delimiter that you are certain will never show up in your data.  Than once you have read that line into a stream, you can use the string functions to parse out the columns as needed:
    CREATE INPUT STREAM csv_instream SCHEMA (
      log_line_message string
    // Choose a character that is certain to never show up in the data in order to read the entire line
    // from the CSV file into a single column
    ATTACH INPUT ADAPTER File_Hadoop_CSV_Input1 TYPE toolkit_file_csv_input TO csv_instream PROPERTIES
      csvExpectStreamNameOpcode = FALSE ,
      dir = 'C:/temp' ,
      file = 'error_log' ,
      csvDelimiter = '@' ;
    // Parse out the individual columns
    CREATE OUTPUT STREAM csv_outstream SCHEMA (
      log_datetime timestamp ,
      debug_level string ,
      host string ,
      message string ) AS SELECT
      to_timestamp(substr(CI.log_line_message, 1, 24), 'DY MON DD HH24:MI:SS YYYY') as log_datetime,
      substr(CI.log_line_message, patindex(CI.log_line_message, '[', 2)+1, (patindex(CI.log_line_message, ']', 2) - patindex(CI.log_line_message, '[', 2))-1) AS debug_level,
      replace(substr(CI.log_line_message, patindex(CI.log_line_message, '[', 3)+1, (patindex(CI.log_line_message, ']', 3) - patindex(CI.log_line_message, '[', 3))-1), 'client ', '') AS host,
      substr(CI.log_line_message, patindex(CI.log_line_message, ']', 3)+1, 500) AS message
      FROM csv_instream CI
      WHERE CI.log_line_message IS NOT NULL;
    Thanks,
    Neal

  • Ordwebutl.cache_status

    I can not find this procedure and not sure how to create it.
    I am using OAS 4.0.8.1 on NT with Oracle 8.1.5
    http_status := ordwebutl.cache_status( db_mod_date,http_if_modified_since,
    http_last_modified );
    I got this sample code "MP3demo" from technet.oracle.com
    Can anyone help...
    Thanks
    null

    <oracle_home>\ord\web\admin\ordwebutl.sql
    Rem Copyright (c) 1998, 1999 by Oracle Corp. All Rights Reserved.
    Rem
    Rem NAME
    Rem ordwebutl
    Rem
    Rem PURPOSE
    Rem Oracle interMedia Web Agent PL/SQL utility package
    Rem
    Rem USAGE
    Rem sqlplus ordsys/<ordsys-password>@database @ordwebutl.sql
    Rem -- OR --
    Rem srvmgr> connect ordsys/<ordsys-password>@database
    Rem svrmgr> @ordwebutl.sql
    Rem
    Rem HISTORY
    Rem jcave 10/20/98 Initial version
    Rem ddiamond 10/22/98 Add public synonym
    Rem ddiamond 10/27/98 Remove the "; length=NNN" from date
    Rem soxbury 11/17/98 Change name to ordwebutl; same as synonym
    Rem soxbury 02/22/99 Add procedures to free temporary LOBs
    Rem ddiamond 03/22/99 Add tables and procedures for IMW catalog
    Rem
    create table mw$catalog_by_typ (
    TYPE_OWNER VARCHAR2(30)
    not null,
    TYPE_NAME VARCHAR2(30)
    not null,
    MEDIA_TYPE VARCHAR2(10)
    not null,
    LOB_TYPE VARCHAR2(10)
    not null,
    LOB_ATT VARCHAR2(100)
    not null
    create table mw$catalog_by_tab (
    TABLE_OWNER VARCHAR2(30)
    not null,
    TABLE_NAME VARCHAR2(30)
    not null,
    KEY_COLUMN VARCHAR2(30)
    not null,
    INSERT_PROC VARCHAR2(30)
    null,
    UPDATE_PROC VARCHAR2(30)
    null
    create table mw$catalog_by_col (
    TABLE_OWNER VARCHAR2(30)
    not null,
    TABLE_NAME VARCHAR2(30)
    not null,
    COLUMN_NAME VARCHAR2(30)
    not null,
    OBJ_GET_PROC VARCHAR2(30)
    null,
    OBJ_PUT_PROC VARCHAR2(30)
    null,
    OBJ_SET_PROC VARCHAR2(30)
    null
    delete from mw$catalog_by_typ where type_name = 'ORDAUDIO';
    insert into mw$catalog_by_typ values (
    'ORDSYS', 'ORDAUDIO', 'AUDIO', 'BLOB', '.SOURCE.LOCALDATA' );
    delete from mw$catalog_by_typ where type_name = 'ORDIMAGE';
    insert into mw$catalog_by_typ values (
    'ORDSYS', 'ORDIMAGE', 'IMAGE', 'BLOB', '.SOURCE.LOCALDATA' );
    delete from mw$catalog_by_typ where type_name = 'ORDVIDEO';
    insert into mw$catalog_by_typ values (
    'ORDSYS', 'ORDVIDEO', 'VIDEO', 'BLOB', '.SOURCE.LOCALDATA' );
    delete from mw$catalog_by_typ where type_name = 'ORDIMGB';
    insert into mw$catalog_by_typ values (
    'ORDSYS', 'ORDIMGB', 'IMAGE', 'BLOB', '.CONTENT' );
    delete from mw$catalog_by_typ where type_name = 'ORDVIR';
    insert into mw$catalog_by_typ values (
    'ORDSYS', 'ORDVIR', 'IMAGE', 'BLOB', '.IMAGE.SOURCE.LOCALDATA' );
    commit work;
    create or replace package ordsys.ordwebutl as
    http_status_ok constant number(3) := 200; /* OK */
    http_status_moved_perm constant number(3) := 301; /* Moved perm. */
    http_status_moved_temp constant number(3) := 302; /* Moved temp. */
    http_status_see_other constant number(3) := 303; /* See other */
    http_status_not_mod constant number(3) := 304; /* Not modified */
    http_status_forbidden constant number(3) := 403; /* Forbidden */
    * Set dbms_server_timezone to the database server's time zone, if its
    * one of the supported time zones (see new_date() SLQ function). If not
    * supported, set dbms_server_gmtdiff to difference in hours from GMT.
    dbms_server_timezone constant varchar2(3) := 'EST';
    dbms_server_gmtdiff constant number := NULL;
    function http_to_oracle_date( http_date in varchar2 ) return date;
    function oracle_to_http_date( ora_date in date ) return varchar2;
    function cache_status( db_lastmod_date in date,
    cli_ifmod_date in varchar2,
    cli_lastmod_date out varchar2 ) return number;
    procedure free_temp_blob( temp_blob in out nocopy blob );
    procedure free_temp_clob( temp_clob in out nocopy clob );
    function get_imw_typ_media_type(
    in_type_owner in varchar2,
    in_type_name in varchar2 )
    return varchar2;
    function get_imw_typ_lob_type(
    in_type_owner in varchar2,
    in_type_name in varchar2 )
    return varchar2;
    function get_imw_typ_lob_att(
    in_type_owner in varchar2,
    in_type_name in varchar2 )
    return varchar2;
    procedure set_imw_typ_info(
    in_type_owner in varchar2,
    in_type_name in varchar2,
    in_media_type in varchar2,
    in_lob_type in varchar2,
    in_lob_att in varchar2 );
    function get_imw_tab_count(
    in_table_name in varchar2 )
    return number;
    function get_imw_tab_key_column(
    in_table_name in varchar2 )
    retu rn varchar2;
    function get_imw_tab_insert_proc(
    in_table_name in varchar2 )
    return varchar2;
    function get_imw_tab_update_proc(
    in_table_name in varchar2 )
    return varchar2;
    procedure set_imw_tab_info(
    in_table_name in varchar2,
    in_key_column in varchar2,
    in_insert_proc in varchar2,
    in_update_proc in varchar2 );
    procedure set_imw_tab_key_column(
    in_table_name in varchar2,
    in_key_column in varchar2 );
    procedure set_imw_tab_insert_proc(
    in_table_name in varchar2,
    in_insert_proc in varchar2 );
    procedure set_imw_tab_update_proc(
    in_table_name in varchar2,
    in_update_proc in varchar2 );
    function get_imw_col_obj_get_proc(
    in_table_name in varchar2,
    in_column_name in varchar2 )
    return varchar2;
    function get_imw_col_obj_put_proc(
    in_table_name in varchar2,
    in_column_name in varchar2 )
    return varchar2;
    function get_imw_col_obj_set_proc(
    in_table_name in varchar2,
    in_column_name in varchar2 )
    return varchar2;
    procedure set_imw_col_info(
    in_table_name in varchar2,
    in_column_name in varchar2,
    in_obj_get_proc in varchar2,
    in_obj_put_proc in varchar2,
    in_obj_set_proc in varchar2 );
    procedure set_imw_col_nothing(
    in_table_name in varchar2,
    in_column_name in varchar2 );
    procedure set_imw_col_obj_get_proc(
    in_table_name in varchar2,
    in_column_name in varchar2,
    in_obj_get_proc in varchar2 );
    procedure set_imw_col_obj_put_proc(
    in_table_name in varchar2,
    in_column_name in varchar2,
    in_obj_put_proc in varchar2 );
    procedure set_imw_col_obj_set_proc(
    in_table_name in varchar2,
    in_column_name in varchar2,
    in_obj_set_proc in varchar2 );
    pragma restrict_references( http_to_oracle_date, WNDS, WNPS );
    pragma restrict_references( oracle_to_http_date, WNDS, WNPS );
    pragma restrict_references( cache_status, WNDS, WNPS );
    pragma restrict_references( get_imw_typ_media_type, WNDS, WNPS );
    pragma restrict_references( get_imw_typ_lob_type, WNDS, WNPS );
    pragma restrict_references( get_imw_typ_lob_att, WNDS, WNPS );
    pragma restrict_references( get_imw_tab_count, WNDS, WNPS );
    pragma restrict_references( get_imw_tab_key_column, WNDS, WNPS );
    pragma restrict_references( get_imw_tab_insert_proc, WNDS, WNPS );
    pragma restrict_references( get_imw_tab_update_proc, WNDS, WNPS );
    pragma restrict_references( get_imw_col_obj_get_proc, WNDS, WNPS );
    pragma restrict_references( get_imw_col_obj_put_proc, WNDS, WNPS );
    pragma restrict_references( get_imw_col_obj_set_proc, WNDS, WNPS );
    end;
    show errors;
    create or replace package body ordsys.ordwebutl as
    * Convert an HTTP GMT-based date to an Oracle date based on the database
    * server's time zone. HTTP format: Wednesday, 25 Mar 1998 18:21:24 GMT
    function http_to_oracle_date( http_date in varchar2 ) return date is
    char_date varchar2( 64 );
    char_pos integer;
    ora_date date;
    begin
    if http_date is null
    then
    * Return NULL if no input date.
    return null;
    else
    /* Start off with the original */
    char_date := http_date;
    * First strip off the "; length=NNN" the way the comments say we're
    * supposed to. DLD, 10/27/98.
    char_pos := instr( char_date, ';' );
    if ( char_pos > 0 )
    then
    char_date := substr( char_date, 1, char_pos - 1 );
    end if;
    * Extract the part of the date we need, convert it to an Oracle date,
    * then adjust to the database server's time zone.
    char_pos := instr( char_date, ',' );
    if (char_pos = 0)
    then
    * Must be an ANSI asctime() date
    char_pos := instr( char_date, ' ');
    char_date := substr( char_date, char_pos );
    ora_date := TO_DATE( char_date, 'MON DD HH24:MI:SS YYYY' );
    else
    * RFC 822 or 850 date, or something similair
    char_date := substr( char_date, char_pos+1 );
    char_pos := instr( char_date, 'GMT' );
    if ( LENGTH(char_date) < char_pos + 3)
    then
    char_date := substr( char_date, 1, char_pos-1 );
    else
    char_date := substr( char_date, 1, LENGTH(char_date)-3 );
    end if;
    ora_date := to_date( char_date, 'DD MON YYYY HH24:MI:SS' );
    if to_char( ora_date, 'YYYY' ) < ' 0100'
    then
    ora_date := to_date( char_date, 'DD MON YY HH24:MI:SS' );
    if (ora_date < TO_DATE('01/01/1980', 'MM/DD/YYYY'))
    then
    ora_date := add_months( ora_date, 1200 );
    end if;
    end if;
    end if;
    if (dbms_server_gmtdiff is not null)
    then
    return ora_date+(dbms_server_gmtdiff/24);
    else
    return new_time(ora_date,'GMT',dbms_server_timezone );
    end if;
    end if;
    end;
    * Convert an Oracle date based on the database server's time zone to an
    * HTTP GMT-based date. HTTP format: Wednesday, 25 Mar 1998 18:21:24 GMT
    function oracle_to_http_date( ora_date in date ) return varchar2 is
    gmt_date date;
    begin
    if ora_date is null
    then
    * Return NULL if no input date.
    return null;
    else
    * Convert time to GMT, then format as per HTTP standard.
    if (dbms_server_gmtdiff is not null)
    then
    gmt_date := ora_date-(dbms_server_gmtdiff/24);
    else
    gmt_date := new_time(ora_date,dbms_server_timezone,'GMT');
    end if;
    return rtrim( substr( to_char( gmt_date, 'DAY' ), 1, 3 ) ) &#0124; &#0124;
    ', ' &#0124; &#0124;
    to_char( gmt_date, 'DD MON YYYY HH24:MI:SS' ) &#0124; &#0124;
    ' GMT';
    end if;
    end;
    * Figure out if a multi-media data item in a brower's cache is up to date.
    * Currently, this algorithm bases its decision only on the date; it should
    * also base the decision on the content length. Note the format of the
    * request: If-Modified-Since: Monday, 23-Mar-98 19:46:10 GMT; length=66
    * Currently, the entire string is passed to http_to_oracle_date(), which
    * is kind enough just to pick out the date.
    function cache_status( db_lastmod_date in date,
    cli_ifmod_date in varchar2,
    cli_lastmod_date out varchar2 ) return number is
    cli_ifmod_date_local date;
    begin
    * Is there a last-modified date associated with the data? If not,
    * there's nothing we can do.
    if db_lastmod_date is not null
    then
    * If the browser is asking if the content has changed, then convert
    * the if-modified date from GMT to local server time zone and
    * compare with the modification date from the database. If the
    * cache is still valid, then set the out-going last-modified date
    * to NULL and return the not-modified status.
    if cli_ifmod_date is not null
    then
    cli_ifmod_date_local := http_to_oracle_date( cli_ifmod_date );
    if db_lastmod_date <= cli_ifmod_date_local
    then
    cli_lastmod_date := null;
    return http_status_not_mod;
    end if;
    end if;
    * Either the browser isn't asking if the cache is valid (because its
    * not in the cache) or the cache is out of date. In either event,
    * set the out-going last-modified date to modification date from
    * database and return the OK status.
    cli_lastmod_date := oracle_to_http_date( db_lastmod_date );
    return http_status_ok;
    else
    * No modification date in the database, so no cache checking can
    * be done; set the out-going last-modified date to NULL and return
    * the OK status.
    cli_lastmod_date := null;
    return http_status_ok;
    end if;
    end;
    * Procedures to free temporary LOBs.
    procedure free_temp_blob( temp_blob in out nocopy blob ) is
    begin
    if dbms_lob.istemporary( temp_blob ) = 1 then
    dbms_lob.freetemporary( temp_blob );
    end if;
    end;
    procedure free_temp_clob( temp_clob in out nocopy clob ) is
    begin
    if dbms_lob.istemporary( temp_clob ) = 1 then
    dbms_lob.freetemporary( temp_clob );
    end if;
    end;
    * Clipboard procedures to access catalog.
    function get_imw_typ_media_type(
    in_type_owner in varchar2,
    in_type_name in varchar2 )
    return varchar2
    is
    ret_media_type varchar2(10);
    begin
    select media_type
    into ret_media_type
    from mw$catalog_by_typ t
    where t.type_owner = in_type_owner
    and t.type_name = in_type_name
    and rownum = 1;
    return ret_media_type;
    end;
    function get_imw_typ_lob_type(
    in_type_owner in varchar2,
    in_type_name in varchar2 )
    return varchar2
    is
    ret_lob_type varchar2(10);
    begin
    select lob_type
    into ret_lob_type
    from mw$catalog_by_typ t
    where t.type_owner = in_type_owner
    and t.type_ name = in_type_name
    and rownum = 1;
    return ret_lob_type;
    end;
    function get_imw_typ_lob_att(
    in_type_owner in varchar2,
    in_type_name in varchar2 )
    return varchar2
    is
    ret_lob_att varchar2(100);
    begin
    select lob_att
    into ret_lob_att
    from mw$catalog_by_typ t
    where t.type_owner = in_type_owner
    and t.type_name = in_type_name
    and rownum = 1;
    return ret_lob_att;
    end;
    procedure set_imw_typ_info(
    in_type_owner in varchar2,
    in_type_name in varchar2,
    in_media_type in varchar2,
    in_lob_type in varchar2,
    in_lob_att in varchar2 )
    is
    counter int;
    begin
    select count(*)
    into counter
    from mw$catalog_by_typ t
    where t.type_owner = in_type_owner
    and t.type_name = in_type_name
    and rownum = 1;
    if counter = 0
    then
    insert into mw$catalog_by_typ values (
    in_type_owner,
    in_type_name,
    in_media_type,
    in_lob_type,
    in_lob_att );
    else
    update mw$catalog_by_typ t set
    media_type = in_media_type,
    lob_type = in_lob_type,
    lob_att = in_lob_att
    where t.type_owner = in_type_owner
    and t.type_name = in_type_name
    and rownum = 1;
    end if;
    end;
    function get_imw_tab_count(
    in_table_name in varchar2 )
    return number
    is
    ret_count int;
    begin
    select count(*)
    into ret_count
    from mw$catalog_by_tab t
    where t.table_owner = user
    and t.table_name = in_table_name;
    return ret_count;
    end;
    function get_imw_tab_key_column(
    in_table_name in varchar2 )
    return varchar2
    is
    ret_key_column varchar2(30);
    begin
    select key_column
    into ret_key_column
    from mw$catalog_by_tab t
    where t.table_owner = user
    and t.table_name = in_table_name
    and rownum = 1;
    return ret_key_column;
    end;
    function get_imw_tab_insert_proc(
    in_table_name in varchar2 )
    return varchar2
    is
    ret_insert_proc varchar2(30);
    begin
    select insert_proc
    into ret_insert_proc
    from mw$catalog_by_tab t
    where t.table_owner = user
    and t.table_name = in_table_name
    and rownum = 1;
    return ret_insert_proc;
    end;
    function get_imw_tab_update_proc(
    in_table_name in varchar2 )
    return varchar2
    is
    ret_update_proc varchar2(30);
    begin
    select update_proc
    into ret_update_proc
    from mw$catalog_by_tab t
    where t.table_owner = user
    and t.table_name = in_table_name
    and rownum = 1;
    return ret_update_proc;
    end;
    procedure set_imw_tab_info(
    in_table_name in varchar2,
    in_key_column in varchar2,
    in_insert_proc in varchar2,
    in_update_proc in varchar2 )
    is
    counter int;
    begin
    select count(*)
    into counter
    from mw$catalog_by_tab t
    where t.table_owner = user
    and t.table_name = in_table_name
    and rownum = 1;
    if counter = 0
    then
    insert into mw$catalog_by_tab values (
    user,
    in_table_name,
    in_key_column,
    in_insert_proc,
    in_update_proc );
    else
    update mw$catalog_by_tab t set
    key_column = in_key_column,
    insert_proc = in_insert_proc,
    update_proc = in_update_proc
    where t.table_owner = user
    and t.table_name = in_table_name
    and rownum = 1;
    end if;
    end;
    procedure set_imw_tab_key_column(
    in_table_name in varchar2,
    in_key_column in varchar2 )
    is
    counter int;
    begin
    select count(*)
    into counter
    from mw$catalog_by_tab t
    where t.table_owner = user
    and t.table_name = in_table_name
    and rownum = 1;
    if counter = 0
    then
    insert into mw$catalog_by_tab (
    table_owner,
    table_name,
    key_column )
    values (
    user,
    in_table_name,
    in_key_column );
    else
    update mw$catalog_by_tab t set
    key_column = in_key_column
    where t.table_owner = user
    and t.table_name = in_table_name
    and rownum = 1;
    end if;
    end;
    procedure set_imw_tab_insert_proc(
    in_table_name in varchar2,
    in_insert_proc in varchar2 )
    is
    counter int;
    begin
    select count(*)
    into counter
    from mw$catalog_by_tab t
    where t.table_owner = user
    and t.table_name = in_table_name
    and rownum = 1;
    if counter = 0
    then
    insert into mw$catalog_by_tab (
    table_owner,
    table_name,
    insert_proc )
    values (
    user,
    in_table_name,
    in_insert_proc );
    else
    update mw$catalog_by_tab t set
    insert_proc = in_insert_proc
    where t.table_owner = user
    and t.table_name = in_table_name
    and rownum = 1;
    end if;
    end;
    procedure set_imw_tab_update_proc(
    in_table_name in varchar2,
    in_update_proc in varchar2 )
    is
    counter int;
    begin
    select count(*)
    into counter
    from mw$catalog_by_tab t
    where t.table_owner = user
    and t.table_name = in_table_name
    and rownum = 1;
    if counter = 0
    then
    insert into mw$catalog_by_tab (
    table_owner,
    table_name,
    update_proc )
    values (
    user,
    in_table_name,
    in_update_proc );
    else
    update mw$catalog_by_tab t set
    update_proc = in_update_proc
    where t.table_owner = user
    and t.table_name = in_table_name
    and rownum = 1;
    end if;
    end;
    function get_imw_col_obj_get_proc(
    in_table_name in varchar2,
    in_column_name in varchar2 )
    return varchar2
    is
    ret_obj_get_proc varchar2(30);
    begin
    select obj_get_proc
    into ret_obj_get_proc
    from mw$catalog_by_col t
    where t.table_owner = user
    and t.table_name = in_table_name
    and t.column_name = in_column_name
    and rownum = 1;
    return ret_obj_get_proc;
    end;
    function get_imw_col_obj_put_proc(
    in_table_name in varchar2,
    in_column_name in varchar2 )
    return varchar2
    is
    ret_obj_put_proc varchar2(30);
    begin
    select obj_put_proc
    into ret_obj_put_proc
    from mw$catalog_by_col t
    where t.table_owner = user
    and t.table_name = in_table_name
    and t.column_name = in_column_name
    and rownum = 1;
    return ret_obj_put_proc;
    end;
    function get_imw_col_obj_set_proc(
    in_table_name in varchar2,
    in_column_name in varchar2 )
    return varchar2
    is
    ret_obj_set_proc varchar2(30);
    begin
    select obj_set_proc
    into ret_obj_set_proc
    from mw$catalog_by_col t
    where t.table_owner = user
    and t.table_name = in_table_name
    and t.column_name = in_column_name
    and rownum = 1;
    return ret_obj_set_proc;
    end;
    procedure set_imw_col_info(
    in_table_name in varchar2,
    in_column_name in varchar2,
    in_obj_get_proc in varchar2,
    in_obj_put_proc in varchar2,
    in_obj_set_proc in varchar2 )
    is
    counter int;
    begin
    select count(*)
    into counter
    from mw$catalog_by_col t
    where t.table_owner = user
    and t.table_name = in_table_name
    and t.column_name = in_column_name
    and rownum = 1;
    if counter = 0
    then
    insert into mw$catalog_by_col values (
    user,
    in_table_name,
    in_column_name,
    in_obj_get_proc,
    in_obj_put_proc,
    in_obj_set_proc );
    else
    update mw$catalog_by_col t set
    obj_get_proc = in_obj_get_proc,
    obj_put_proc = in_obj_put_proc,
    obj_set_proc = in_obj_set_proc
    where t.table_owner = user
    and t.table_name = in_table_name
    and t.column_name = in_column_name
    and rownum = 1;
    end if;
    end;
    procedure set_imw_col_nothing(
    in_table_name in varchar2,
    in_column_name in varchar2 )
    is
    counter int;
    begin
    select count(*)
    into counter
    from mw$catalog_by_col t
    where t.table_owner = user
    and t.table_name = in_table_name
    and t.column_name = in_column_name
    and rownum = 1;
    if counter = 0
    then
    insert into mw$catalog_by_col (
    table_owner,
    table_name,
    column_name )
    values (
    user,
    in_table_name,
    in_column_name );
    end if;
    end;
    procedure set_imw_col_obj_get_proc(
    in_table_name in varchar2,
    in_column_name in varchar2,
    in_obj_get_proc in varchar2 )
    is
    counter int;
    begin
    select count(*)
    into counter
    from mw$catalog_by_col t
    where t.table_owner = user
    and t.table_name = in_table_name
    and t.column_name = in_column_name
    and rownum = 1;
    if counter = 0
    then
    insert into mw$catalog_by_col (
    table_owner,
    table_name,
    column_name,
    obj_get_proc )
    values (
    user,
    in_table_name,
    in_column_name,
    in_obj_get_proc );
    else
    update mw$catalog_by_col t set
    obj_get_proc = in_obj_get_proc
    where t.table_owner = user
    and t.table_name = in_table_name
    and t.column_name = in_column_name
    and rownum = 1;
    end if;
    end;
    procedure set_imw_col_obj_put_proc(
    in_table_name in varchar2,
    in_column_name in varchar2,
    in_obj_put_proc in varchar2 )
    is
    counter int;
    begin
    select count(*)
    into counter
    from mw$catalog_by_col t
    where t.table_owner = user
    and t.table_name = in_table_name
    and t.column_name = in_column_name
    and rownum = 1;
    if counter = 0
    then
    insert into mw$catalog_by_col (
    table_owner,
    table_name,
    column_name,
    obj_put_proc )
    values (
    user,
    in_table_name,
    in_column_name,
    in_obj_put_proc );
    else
    update mw$catalog_by_col t set
    obj_put_proc = in_obj_put_proc
    where t.table_owner = user
    and t.table_name = in_table_name
    and t.column_name = in_column_name
    and rownum = 1;
    end if;
    end;
    procedure set_imw_col_obj_set_proc(
    in_table_name in varchar2,
    in_column_name in varchar2,
    in_obj_set_proc in varchar2 )
    is
    counter int;
    begin
    select count(*)
    into counter
    from mw$catalog_by_col t
    where t.table_owner = user
    and t.table_name = in_table_name
    and t.column_name = in_column_name
    and rownum = 1;
    if counter = 0
    then
    insert into mw$catalog_by_col (
    table_owner,
    table_name,
    column_name,
    obj_set_proc )
    values (
    user,
    in_table_name,
    in_column_name,
    in_obj_set_proc );
    else
    update mw$catalog_by_col t set
    obj_set_proc = in_obj_set_proc
    where t.table_owner = user
    and t.table_name = in_table_name
    and t.column_name = in_column_name
    and rownum = 1;
    end if;
    end;
    end;
    show errors;
    CREATE PUBLIC SYNONYM ORDWEBUTL FOR ORDSYS.ORDWEBUTL;
    GRANT EXECUTE ON ORDSYS.ORDWEBUTL TO PUBLIC;
    null

  • Default Date Mask

    Hi All,
    We have about 15 business areas with 100+ folders each. Does anyone know how we can change the default date mask without going into every single folder and changing it for every date item?
    Thank you,
    MIS

    Hi,
    I think the only way to do this is to hack the EUL table using SQL*Plus. Fine if you backup and know what you are doing, but otherwise a recipe for disaster.
    The table you want to change is EUL5_EXPRESSIONS, so for example, to change the default date mask for all audit date columns (item name begining with Audit) from DD-MON-RRRR to DD-Month-YYYY you can use this SQL:
    update eul5_expressions
    set it_format_mask = 'fmDD-Month-YYYY'
    where exp_type = 'CO'
    and exp_data_type = 4
    and exp_name like 'Audit%'
    and it_format_mask = 'DD-MON-RRRR'Rod West

Maybe you are looking for

  • Error no 6474 in PO

    I m creating a PO with reference to a contract. Tt is a value contract. While creating PO it gives an error that "Please specify short text more precisely" error Message no. 06474. But how can I enter this as the material shot text is grey. I don't w

  • Will a macbook air be enough for my needs?

    Hello everyone, I'm looking to get a new mac, and I am in a bit of a dilemma between the MBA and the MBP (non retina). First of all, let me explain that the reasons for not getting the retina are basically that I feel a bit uncomfortable/scared becau

  • Equipment to be sent to contractor for repairs

    PM Gurus; In a scenario, I want to send equipment for repairs to contractor and also track the maintenance cost on 'maintenance order'. I am following the steps; 1) For every equipment, one non valuated material is created in MM 2) Maintenance order

  • Why is my iPhone 4 screen not displaying properly?

    Hello everyone, I have had my iPhone 4 now for a few months and it has worked fine until today. The screen suddenly displayed multi-coloured moving lines and coloured blocks randomly in succession, before turning bright green. I plugged it into my co

  • Update to 8.2 invalid G drive error ?

    Never had a problem with previous versions but I can't upgrade to 8.2? Always tells me I have an invalid G Drive ??? Any help please !