implicit conversion to sql

Hi guys,.

I have a question on how the oracle is posting implicit conversion in the following cases.

I have a table: table1 with two columns: a number (10), b varchar2 (10). Both are indexed unique.


If I have a SQL like this:
select * from table1 where a = '99'
the implicit conversion is performed on '99' and the final SQL will be something like:
select * from table1 where a = to_number ('99')
the same thing will happen with 'aaa' and I get an error. Please note that represents the column and the index will be used.

If I have a sql like:
select * from table1 where b = 99
Note that b is the varchar2 column.
the implicit conversion will be done on the column and the index will not be used
select * from table1 where to_number (b) = 99
THEN, forgetting for a moment that it is not OK to allow an implicit conversion, what are the rules that apply here? If the number, the conversion will be made on the value and varchar conversion will be performed on the column? What else?


Thank you

http://docs.Oracle.com/CD/E11882_01/server.112/e26088/sql_elements002.htm#SQLRF51047

Tags: Database

Similar Questions

  • If an implicit conversion takes place

    Hi all

    I have two queries tell

    SQL > SELECT * FROM EMP WHERE HIREDATE BETWEEN February 20, 81 'AND February 20, 82';

    EMPNO, ENAME, JOB HIREDATE DEPTNO COMM SAL MGR
    ----- ---------- --------- ---------- --------- ---------- ---------- ----------
    7499 ALLEN 7698 1600 20 FEBRUARY SALESMAN 81 300 30
    7521 WARD 7698 1250 22 FEBRUARY SALESMAN 81 500 30
    7566 JONES MANAGER 7839 2975 2 APRIL 81 20
    7654 MARTIN 7698 28 - SEP - 81 1250 1400 30 SALESMAN
    7698 BLAKE MANAGER 7839 2850 MAY 1, 81 30
    7782 10 removed MANAGER 7839 2450 June 9 81 10
    7839 10 deleted PRESIDENT November 17, 81 5000 10
    7844 TURNER 7698 08 - SEP - 81 1500 0 30 SALESMAN
    7900 7698 DECEMBER 3, CLERK JAMES 81 950 30
    7902 7566 3000 3 DECEMBER ANALYST FORD 81 20
    7934 10 deleted CLERK 7782 1300 January 23 82 10

    AND

    SQL > select' 17-SEP-2010 + 1 double;

    ERROR on line 1:
    ORA-01722: invalid number

    now in the first case, I spent a string and that turned into a date
    but in the second case, I try to add a day to this date it is not be converted in the second case.

    When in fact the implicit conversion is done.

    Thank you and best regards,
    Sri ram.

    Probably below may be the reason.
    In the first query you asked oracle to match the hiring date between two dates. Oracle implicitley equal strings depending on the hiring date data type.
    But in the 2nd query you specify a string in your oracle query does not include what format to convert the string.

  • CVI2013: WARNING: implicit conversion changes signedness: "long" to "int".

    What is Clang was trying to say with this warning?

    int f( void )
    {
      int i1 = 4;
    
      int i2 = 1l << ( i1 - 1 );
      //       ^^  warning: implicit conversion changes signedness: 'long' to 'int' [-Wsign-conversion]
    
      return i2;
    }
    

    Hello CVI - User!

    The explanation is quite technical...

    The result type of the expression of SHIFT is "signed for a long time." The target type of the initialization is "signed int". Clang injects an implicit "signed long" conversion to "signed int" and check the different properties of the conversion.

    In particular, clang tests if the sign of the value can change during the conversion. For this test, clang calculates the range of 'values' of the source 1 L< (i1="" -="" 1)'="" and="" the="" "value="" range"="" of="" the="" target="" 'int="" i2'.="" the="" warning="" indicates="" that="" the="" signs="" of="" the="" source="" and="" target="" ranges="" do="" not="">

    The range of values of the source depends on the expression 1 L< (i1="" -="" 1)'="" and="" here="" clang="" is="" applying="" a="" special="">

        [excerpt from GetExprRange in the clang 2.9 source code]
    
        // Left shift gets black-listed based on a judgement call.
        // ...except that we want to treat '1 << (blah)' as logically
        // positive.  It's an important idiom.
    

    Therefore the range of values of source is: wide, 32-bit positive.

    The range of values of the target depends on the type of "i2" and that's the range of default values for "signed int": 32 - bit wide, positive or negative.

    In other words: 1 L< (i1="" -="" 1)'="" is="" considered="" positive="" (unsigned)="" and="" it="" is="" converted="" to="" a="" signed="">

    Note that this is really a special case and that you do not get the warning for other values:

      int i2 = 2l << ( i1 - 1 ); //no warning
    

    Unfortunately, I can not explain why clang didn't just compare the source and target types, it calculates the ranges of values and why 1< (blah)'="" is="" treated="" specially.="" i="" don't="">

    Peter

  • TopLink grid 11g: conversion of SQL queries to the filters of consistency

    I would like to know how efficient the conversion of SQL queries for filters of coherence is wen search an object in the cache coherence. TopLink does something as instruction cache cache filters consistency as well? In this regard, you have number of performance?

    Thank you very much!

    Ming-Wen

    TopLink grid currently has a rudimentary filter cache that allows TopLink to only translate NamedQuery once. This allows TopLink grid to reuse the same filter on subsequent runs of this NamedQuery.
    -Gordon

  • Conversion of SQL Query Help

    Hello, I'm doing a migration of SQL Server T - SQL to oracle 11 g PL/SQL, and I don't want to use a global temporary table; Instead, consider using sliders and pl/sql table.

    I got hit in a scenario where I need to convert the following in a single sql statement.

    Stage of T - SQL:
    ============

    Insert (#ActCde)
    InvntrySbLdgrChngeID
    DlHdrID
    DlDtlID
    ChemID
    StrtgyID
    Quantity
    Value
    Modified)
    Select InvntrySbLdgrChngeID
    DlHdrID
    DlDtlID
    ChildPrdctID
    StrtgyID
    VolumeChanged
    ValueChanged
    , 'N'
    of InventorySubLedgerChange
    where LastInChain = 'Y '.

    -updated column "Changed" of particular documents to 'Y' based on conditions

    Update #ActCde
    Changed the value = 'Y '.
    of #ActCde (nolock)
    Left Outer Join InventorySubledgerDetail ISD (nolock)
    on #ActCde.DlHdrID = DSI. DlDtlChmclDlDtlDlHdrID
    and #ActCde.DlDtlID = ISD. DlDtlChmclDlDtlID
    and #ActCde.ChemID = DSI. DlDtlChmclChmclChldPrdctID
    and #ActCde.StrtgyID = DSI. StrtgyID
    and the DSI. AccntngPrdID = @i_AccntngPrdID - variable parameter
    Where abs (#ActCde.Qty - isnull (ISD.) BeginningVolume, 0)) >.01
    or abs (#ActCde.Value - isnull (ISD.) BeginningValue, 0)) >.01
    or (abs(#ActCde.Qty) = 0 and)
    ABS(#ActCde.value) = 0 and
    ABS (isnull (ISD. BeginningVolume, 0)) = 0 and
    ABS (isnull (ISD. BeginningValue, 0)) = 0
    )

    Convertion of SQL:
    ===============
    I would like to do something like

    Select A.InvntrySbLdgrChngeID,
    A.DlHdrID,
    A.DlDtlID,
    A.ChemID,
    A.StrtgyID,
    A.Qty,
    A.Value,
    A.Changed
    Of
    (select InvntrySbLdgrChngeID
    DlHdrID
    DlDtlID
    ChildPrdctID AS ChemID
    StrtgyID
    VolumeChanged AS Qty,
    ValueChanged value have
    , 'N'
    of InventorySubLedgerChange
    where LastInChain = 'Y') A LEFT OUTER JOIN InventorySubledgerDetail B
    ON A.DlHdrID = B.DlDtlChmclDlDtlDlHdrID
    and A.DlDtlID = B.DlDtlChmclDlDtlID
    and A.ChemID = B.DlDtlChmclChmclChldPrdctID
    and A.StrtgyID = B.StrtgyID
    and B.AccntngPrdID = i_AccntngPrdID - parameter varibale
    Where abs (A.Qty - isnull(B.BeginningVolume,0)) >.01
    or abs (A.Value - isnull(B.BeginningValue,0)) >.01
    or (abs (A.Qty) = 0 and)
    ABS (A.value) = 0 and
    ABS (IsNull(B.BeginningVolume,0)) = 0 and
    ABS (IsNull(B.BeginningValue,0)) = 0
    )

    And I need to change the 'A.CHANGED' column value 'Y', based on the outer join, as is above T - SQL.

    IF this wont work so pls help me to another way to do this.

    in this regard, your help is appreciated.

    Thank you!

    SS

    Try this

    select #ActCde.InvntrySbLdgrChngeID
           , #ActCde.DlHdrID
           , #ActCde.DlDtlID
           , #ActCde.ChildPrdctID
           , #ActCde.StrtgyID
           , #ActCde.VolumeChanged
           , #ActCde.ValueChanged
           , case when abs(#ActCde.Qty - isnull(ISD.BeginningVolume,0)) > .01  or
                       abs(#ActCde.Value - isnull(ISD.BeginningValue,0)) > .01 or
                       (
                             abs(#ActCde.Qty)                   = 0 and
                             abs(#ActCde.Value)                 = 0 and
                             abs(isnull(ISD.BeginningVolume,0)) = 0 and
                             abs(isnull(ISD.BeginningValue,0))  = 0
                       )
                  then 'Y'
                  else 'N'
             end changed
      from InventorySubLedgerChange #ActCde
      Left Outer Join InventorySubledgerDetail ISD (nolock)
        on #ActCde.DlHdrID = ISD.DlDtlChmclDlDtlDlHdrID
       and #ActCde.DlDtlID= ISD.DlDtlChmclDlDtlID
       and #ActCde.ChemID = ISD.DlDtlChmclChmclChldPrdctID
       and #ActCde.StrtgyID = ISD.StrtgyID
       and ISD.AccntngPrdID = @i_AccntngPrdID - paramenter variable
     where LastInChain = "Y"
    
  • Conversion of SQL worksheet.

    Hello

    If I sent someone a microsoft excel spreadsheet, the chances that you would be able to convert in SQL if I named a few tables and columns that were to be used are there?

    Please let me know,

    Thank you SM.

    If your excel workbook is formatted so that you have a 'table' by the worksheet contained in it and the first row on the worksheet defines column names and the following lines are the data, then you can treat the workbook as an external database using the ODBC Excel driver.

    Set up:

    1- Go to Control Panel>Administrative Tools>Data Sources (ODBC)>System DSN and create a data source with appropriate driver. Name it EXCL. 
    
    2- In %ORACLE_HOME%\Network\Admin\Tnsnames.ora fie add entry:
    
    EXCL =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.12.0.24)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SID = EXCL)
    )
    (HS = OK)
    )
    
    Here SID is the name of data source that you have just created.
    
    3- In %ORACLE_HOME%\Network\Admin\Listener.ora file add:
    
    (SID_DESC =
    (PROGRAM = hsodbc)
    (SID_NAME = )
    (ORACLE_HOME = )
    )
    
    under SID_LIST_LISTENER like:
    
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = d:\ORA9DB)
    (PROGRAM = extproc)
    )
    (SID_DESC =
    (GLOBAL_DBNAME = ORA9DB)
    (ORACLE_HOME = d:\ORA9DB)
    (SID_NAME = ORA9DB)
    )
    (SID_DESC =
    (PROGRAM = hsodbc)
    (SID_NAME = EXCL)
    (ORACLE_HOME = D:\ora9db)
    ) ) 
    
    Dont forget to reload the listener 
    
    c:\> lsnrctl reload
    
    4- In %ORACLE_HOME%\hs\admin create init.ora. For our sid EXCL we create file initexcl.ora.
    
    In this file set following two parameters:
    
    HS_FDS_CONNECT_INFO = excl
    HS_FDS_TRACE_LEVEL = 0
    
    5- Now connect to Oracle database and create database link with following command:
    
    SQL> CREATE DATABASE LINK excl
    2 USING 'excl'
    3 /
    
    Database link created.
    
    Now you can perform query against this database like you would for any remote database.
    SQL> SELECT table_name FROM all_tables@excl;
    
    TABLE_NAME
    ------------------------------
    DEPT
    EMP
    

    Or refer to this Article...
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:4406709207206

  • need of a conversion in sql criteria

    Hi all

    I have a situation where I need help from you guyz. Kindly help, if you could. I have an output of the query to an array of data as follows:

    SELECT OBJECT_ID PO_num

    , DECODE (SEQUENCE_NUM, 1,' 1 approver: ', 2,' 2nd approver: ', 3, '3rd approver', 4,' 4th approver: ', 5,' 5th approver:', Null) APPROVER_Num

    EMPLOYEE_NAME | ' @ ' || to_char(ACTION_DATE, 'DD-mon-YY hh12:mi:SS AM') APPROVER_ACTION

    OF PO_ACTION_HISTORY_V

    WHERE OBJECT_TYPE_CODE = 'PO '.

    AND SEQUENCE_NUM <>0

    and object_id = 129302 - in. header id

    ORDER BY SEQUENCE_NUM

    PO_NUMAPPROVER_NUMAPPROVER_ACTION
    1293021 approver:Anwar, M. Muhammad Naveed
    1293022nd approver:Iqbal, M. Zafar
    1293023rd approverAzeem, Mr. Muhammad Ali
    1293024th approver:Mr. Faisal Masood Ali Khan
    1293025th approver:Tijuana, Mr. Rizwan Ali

    But I need a query to get something like the following:

    PO_NUM1 approver:2nd approver:3rd approver4th approver:5th approver:
    129302Anwar, M. Muhammad NaveedIqbal, M. ZafarAzeem, Mr. Muhammad AliMr. Faisal Masood Ali KhanTijuana, Mr. Rizwan Ali

    Kindly help!

    Concerning

    Shabbir

    so, something like this:

    SELECT OBJECT_ID PO_num

    , MAX (DECODE (SEQUENCE_NUM, 1,' 1 approver:' | employee_name)) AS '1 approver.

    , MAX (DECODE (SEQUENCE_NUM, 2,' 2nd approver:' | employee_name)) AS '2nd approver.

    , MAX (DECODE (SEQUENCE_NUM, 3,' 3rd approver:' | employee_name)) AS "3rd approver.

    , MAX (DECODE (SEQUENCE_NUM, 4,' 4th approver:' | employee_name)) AS '4th approver.

    , MAX (DECODE (SEQUENCE_NUM, 5,' 5th approver:' | employee_name)) AS '4th approver.

    OF PO_ACTION_HISTORY_V

    WHERE OBJECT_TYPE_CODE = 'PO '.

    AND SEQUENCE_NUM <> 0

    AND object_id = 129302 - in. header id

    Group by object_id, object_type_code

    /

    HTH

  • The implicit conversion of "char to number" or "number of char".

    CREATE TABLE test_table
    (
    NUM NUMBER,
    VCH VARCHAR2 (10)
    );

    INSERT INTO table_test VALUES
    (1, '1') ;

    INSERT INTO table_test VALUES
    (2, '2') ;

    SELECT * FROM test_table WHERE vch = 1;

    When comparing, what type of data is converted into what - all vch values are converted in number or 1 is converted to char '1'?

    Hello

    Welcome to the forum!

    The answer to your question is in the predicate explain plan section:

    filter predicates: to_number ("VCH") = 1

    Best regards
    Nikolai

  • Implicit conversion

    Hi gurus,

    IM test cast of oracle database and describe this Hovanessian:

    create table girot (a varchar2 (30));
    insert into values girot ('9857");
    insert into values girot ('9855');

    Select * from gggg where a = 9857 - OK

    but another table in my database is error:

    Select usur_nmlogin in the seguranca.usuario where usur_id = 99014528
    9855

    Select * from seguranca.usuario
    where usur_nmlogin = 9855;

    ORA-01722: invalid number
    01722 00000 - "invalid number."
    * Cause:
    * Action:


    table describe:
    CREATE TABLE "SEGURANÇA. "" USER ".
    (
    ACTIVATE THE 'USUR_ID' NUMBER(*,0) NOT NULL,
    ACTIVATE THE 'UTIP_ID' NUMBER(*,0) NOT NULL,
    NUMBER(*,0) "FUNC_ID"
    ACTIVATE THE "USUR_NMLOGIN" VARCHAR2 (11 BYTE) NOT NULL,
    VARCHAR2 (40 BYTE) "USUR_NMSENHA");




    I do not understand this!

    Well, since your column is a varchar2, use a varchar2 thus setting. Place the value in quotes should work.

    Nicolas.

  • Why sys_extract_utc (sysdate) training never block pl/sql error?

    Oracle 11.2
    --
    I can't use
    SELECT sys_extract_utc(sysdate) FROM DUAL
    But I can't use
    v := sys_extract_utc(sysdate)
    in a procedure or a trigger without causing an error in compilation or execution.

    In my view, the function sysdate return value does not contain any information of time zone, so he shouldn't be able to be used as a parameter to sys_extract_utc function, because she needs zone information to perform the conversion.

    Clues?

    Thanks in advance.

    Just pl/sql has an implicit conversion. where sql can not for function return types. run in sql, it also works...

    Select sys_extract_utc (to_timestamp (sysdate)) of double;

  • Error when the concatenation of CLOB using conversion implicit to_char

    Hello

    Please look at the code below (Oracle 11.1.0.7.0):
    DECLARE
      c CLOB;
    BEGIN
      FOR i IN 1..10
      LOOP
        -- Please uncomment ONE of the lines below
        c := c ||  LPAD('x', 8000, 'z') || i; -- raises error ora-06502
        --c := c || (LPAD('x', 8000, 'z') || i);  -- works
        --c := c ||  LPAD('x', 8000, 'z') || to_char(i);  -- works
      END LOOP;
    END;
    OK, making use of implicit type conversion may not be the best thing to do, but just out of curiosity, is there any explanation for this error to occur?

    It seems that, when an implicit conversion is involved without the help of hooks, Oracle tries to convert all in varchar2 before concatenate in the clob, which causes the error.

    Thank you
    Luis

    Hello
    >
    # 6.1, we have a clob and a varchar2, as in #2; Why Oracle has decided to convert the clob in varchar2 as you say, and not vice versa as in #3?
    >

    # 5, we have clob and number at the beginning. In order to evaluate the expression oracle requires that two variables was of the same type.
    As the implicit conversion there is no number-> clob
    but there are several-> varchar2 and clob-> varchar2 oracle choose this one.

  • SQL Server-&gt; conversion Oracle database FDM

    Anyone has any experience in the conversion from SQL Server to Oracle for FDM? (11.1 oracle now supports).

    My thought would be to re - treat all files of importation rather than try a conversion of database type.

    Thoughts?

    Thank you

    -John

    John,

    FDM has always support Oracle DB as a repository.

    To convert the SQL Server DB to an Oracle DB server, you have to re-create the metadata for the application at hand. Currently, the feature export to XML of FDM does not take into account differences in filing structures and cannot be used.

    You must then re-import all files or continue on creating this day with impatience.

    Thank you.

  • SQL output varies depending on the value with or without single quotes

    Hello

    My version of the database is the database Oracle 11 g Enterprise Edition Release 11.2.0.1.0 - Production PL/SQL Release 11.2.0.1.0 - Production.


    (1) when I use the query select * from hr.employee where id > = '82210' I get the below of lines


    13205 selected lines.


    2.) when I use the query select * from hr.employee where id > = 82210 I get the below of lines


    11871 selected lines.


    The ID table in hr.employee is ID NOT NULL VARCHAR2 (80).


    I don't have much knowledge in SQL so please can someone explain why this difference in output?


    Kind regards

    007





    Look at the example

    create the table test16

    (

    Identification number,

    SAL varchar2 (10),

    name varchar2 (20)

    );

    insert into test16 values (1, "2005", "ABC");

    insert into test16 values (2, '2045', 'ABC');

    insert into test16 values (3, '2065', 'ABC');

    insert into test16 values (4, '2075', 'ABC');

    insert into test16 values (5, '1705', 'ABC');

    insert into test16 values (6, '1805', 'ABC');

    insert into test16 values (7, '1920', 'ABC');

    insert into test16 values (8, '2010', 'ABC');

    insert into test16 values (9, '0999', 'ABC');

    insert into test16 values (10, '0789', 'ABC');

    insert into test16 values (11, '510', 'ABC');

    insert into test16 values (12, '455', 'ABC');

    commit;

    Select * from test16 where sal > = 200;

    All 12 rows selected because there is an implicit conversion from column sal in numbers

    Select * from test16 where sal > = "200";

    Only 7 rows selected but waited 12

    2005

    2045

    2065

    2075

    2010

    510

    455

    Only the sal of lines that begin with a 2 character or more, those who are selected.

    Another 1805,1920 sal... .are not selected

    Note: Don't store the numbers in a column varchar2.

  • Getting Ora-06502: PL/SQL of Numeric or value error.

    Hello

    I m getting the following error when a calculation for form fields.

    ""Server Ajax Call returned error Ora-06502: PL/SQL digital error or value ".

    I m using the dynamic action to calculate my value fields display. Here is the code of my DA.

    (Required value) event: change

    Selection type (required): product (s)

    Article (s) (required): P141_PROP_COST, P141_DOWNPAY_AMT, P141_PREM_PERC, P141_DOWNPAY_PERC, P141_PREM_AMT



    Begin

    : P141_TOTAL_SELL_PRICE: =: P141_DOWNPAY_AMT +: P141_PREM_AMT;

    : P141_COMM_AMT: =: P141_TOTAL_SELL_PRICE*.02;

    : P141_TOTAL_SELL_PRICE_FEE: =: P141_TOTAL_SELL_PRICE +: P141_TRANSFER_COST +: P141_COMM_AMt;

    : P141_INST_REM_AMT: =: P141_PROP_COST-: P141_DOWNPAY_AMT;

    End;

    Page point to presented: P141_PROP_COST, P141_DOWNPAY_AMT, P141_PREM_AMT, P141_TRANSFER_COST

    Return point page: P141_TOTAL_SELL_PRICE, P141_COMM_AMT, P141_TOTAL_SELL_PRICE_FEE, P141_INST_REM_AMT

    I m using another DA for the calculation and validation of my form fields rest. Here is the code:

    {$("#P141_DOWNPAY_PERC").change (function ()}

    var x = ($("#P141_DOWNPAY_PERC").val () / 100) * $("#P141_PROP_COST").val ();

    $("#P141_DOWNPAY_AMT").val (x);

    });

    {$("#P141_DOWNPAY_AMT").change (function ()}

    If ($("#P141_DOWNPAY_AMT").val () > $("#P141_PROP_COST").val ())

    {

    Alert ("section may be no greater than the basic price");

    }

    on the other

    {var y = ($("#P141_DOWNPAY_AMT").val () / ($("#P141_PROP_COST").val ())) * 100;}

    y = Math.Round (y);

    $("#P141_DOWNPAY_PERC").val (y) ;}

    });

    {$("#P141_PREM_PERC").change (function ()}

    var x = ($("#P141_PREM_PERC").val () / 100) * $("#P141_PROP_COST").val ();

    $("#P141_PREM_AMT").val (x);

    });

    {$("#P141_PREM_AMT").change (function ()}

    If ($("#P141_PREM_AMT").val () > $("#P141_PROP_COST").val ())

    {

    Alert ("section may be no greater than the basic price");

    }

    on the other

    {var z = ($("#P141_PREM_AMT").val () / ($("#P141_PROP_COST").val ())) * 100;}

    z = Math.Round (z);

    $("#P141_PREM_PERC").val (z) ;}

    });

    Any help.

    Concerning

    Pa

    'Problems of implicit conversion' comes to mind when I see this:

    : P141_TOTAL_SELL_PRICE: =: P141_DOWNPAY_AMT +: P141_PREM_AMT;

    This is similar to the problems I've seen when using the default formats for the Date Picker Item Types.

    I will add in some APEX_DEBUG. MESSAGE() lines to check what are the string values.

    (remember, all bind variables are of type VARCHAR2)

    You should maybe explicitly to convert strings to numbers using TO_NUMBER() and include the appropriate format.

    (a bit like you have to do with the conversion of strings to dates.)

    My $0.02 worth

    MK

  • Problem with Sql Loader

    Hi s/n,.

    I am facing problems when loading the dates in the database by using sql loader. My data file can have several date formats, so I have a function that interprets date and removes the time settings and the date of return.

    Something like that.

    For example:

    I have a table-

    CREATE TABLE TEMP1234

    (

    IDENTIFICATION NUMBER,

    DATE OF ASOF_DATE

    );

    Data file

    10001172 | 09/12/1945

    Control file:

    OPTIONS (DIRECT = TRUE, SILENT (FEEDBACK) =, skip = 0)

    DATA RELATING TO SUNK COSTS

    REPLACE

    in the temp1234 table

    ' fields completed by "|" possibly provided by ' "'

    TRAILING NULLCOLS

    (ID,

    ASOF_DATE "decode (: ASOF_DATE, null,:ASOF_DATE,conv_date1(:ASOF_DATE))).

    )

    Function CONV_DATE1:

    FUNCTION to CREATE or REPLACE conv_date1 (p_str IN VARCHAR2)
    DATE OF RETURN
    IS
    RETURN_VALUE DATE;

    p_str1 VARCHAR2 (15): = NULL;

    FmtArray TYPE IS a TABLE OF VARCHAR2 (30);

    g_fmts fmtArray
    : = fmtArray ("yyyy-mm-dd",
    "yyyy/mm/dd"
    mm/dd/yyyy"."
    "dd-mm-yyyy",
    "dd/mm/yyyy",
    "mm-dd-yyyy");
    BEGIN
    p_str1: = SUBSTR (p_str, 1, 10);

    BECAUSE me in 1... g_fmts. COUNTY
    LOOP
    BEGIN
    return_value: = TO_DATE (p_str1, g_fmts (i));
    EXIT;
    EXCEPTION
    WHILE OTHERS
    THEN
    NULL;
    END;
    END LOOP;

    IF (return_value IS NULL)
    THEN
    RAISE PROGRAM_ERROR;
    END IF;

    RETURN Return_value;
    END;
    /

    In this case, if the year in the data file shown in 1945, date which is load in the poster 2045 database.

    But when I run this function by putting a sql editor - it returns the correct value.

    Select double conv_date1('12/09/1945');

    Please help me understand what is causing the problem.

    I think there may be an implicit conversion going on with the combination of decode and checking nvl and function within SQL * Loader.  I put the nvl checking in function and simply use the function in the control file, as shown below.

    OPTIONS (DIRECT = TRUE, SILENT (FEEDBACK) =, skip = 0)

    DATA RELATING TO SUNK COSTS

    REPLACE

    in the temp1234 table

    ' fields completed by "|" possibly provided by ' "'

    TRAILING NULLCOLS

    (ID,

    asof_date ' conv_date1 (: asof_date).

    )

    FUNCTION to CREATE or REPLACE conv_date1 (p_str IN VARCHAR2)

    DATE OF RETURN

    IS

    RETURN_VALUE DATE;

    p_str1 VARCHAR2 (15): = NULL;

    FmtArray TYPE IS a TABLE OF VARCHAR2 (30);

    g_fmts fmtArray

    : = fmtArray ("yyyy-mm-dd",

    "yyyy/mm/dd"

    mm/dd/yyyy"."

    "dd-mm-yyyy",

    "dd/mm/yyyy",

    "mm-dd-yyyy");

    BEGIN

    IF p_str IS NULL

    THEN RETURN NULL;

    ON THE OTHER

    p_str1: = SUBSTR (p_str, 1, 10);

    BECAUSE me in 1... g_fmts. COUNTY

    LOOP

    BEGIN

    return_value: = TO_DATE (p_str1, g_fmts (i));

    EXIT;

    EXCEPTION

    WHILE OTHERS

    THEN

    NULL;

    END;

    END LOOP;

    IF (return_value IS NULL)

    THEN

    RAISE PROGRAM_ERROR;

    END IF;

    RETURN Return_value;

    END IF;

    END;

    /

Maybe you are looking for