TO_NUMBER

Hello,
I've got :
cNumber varchar2(10);
nNumber number;
cNumber := 'FE1';
I need to add +2 to cNumber and returns then FE3. How should I proceed ?
I thought of :nNumber := TO_NUMBER(cNumber);
nNumber := nNumber + 2;
cNumber := TO_CHAR(nNumber);
But even the nNumber := TO_NUMBER(cNumber) doesn't work.
Any help appreciated.
Jerome.

You have to remove the 'FE' from the to_number call. If you always know that the first 2 chars are non-numeric (and not to partake in the number conversion) then do something like this:
select substr('FE3',1,2) || to_char(to_number(substr('FE3',3)) + 1) from dual
Tom Best

Similar Messages

  • To_number function doesn't work with apex_collections in where clause

    One of my applications I have been using apex_collections and to_number function
    in the where clause. Since we upgraded apex to version 3.0.1 , it gives the invalid number error.
    Is this a bug in the new Version.
    I had to re-write the logic to fix the application.

    Can you show us that code? An example on apex.oracle.com where we can see the error would be great.
    Scott
    P.S. Please tell us your first name and put it into your handle and/or profile to help us.

  • Issue with to_number

    Hello all.
    Please explain me the following phenomena, i cant figure this out.
    Why is 'to_number' function forced by the optimizer in this query @ the operation number 11 ?
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL>
    SQL>
    SQL>
    SQL> explain plan for
      2  with q as (
      3    select v$parameter.value bs_value
      4    from v$parameter
      5    where name='db_block_size'
      6  )
      7  select a.username,
      8         a.sid, a.serial#,
      9         round(((b.blocks*bs_value)/1024/1024),2) size_mb,
    10         a.status,
    11         b.segfile#,
    12         b.segblk#
    13  from v$session a,
    14       v$sort_usage b,
    15       v$process c,
    16       q
    17  where a.saddr = b.session_addr
    18    and a.paddr = c.addr
    19    and ((nvl(b.blocks,0)*nvl(bs_value,0))/1024/1024) > 0
    20  -- group by b.segfile#, b.segblk#,
    21  order by size_mb;
    Explained.
    SQL>
    SQL>
    SQL> set linesize 250
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3927520946
    | Id  | Operation                    | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                 |     1 |   668 |     3 (100)| 00:00:01 |
    |   1 |  SORT ORDER BY               |                 |     1 |   668 |     3 (100)| 00:00:01 |
    |   2 |   NESTED LOOPS               |                 |     1 |   668 |     2 (100)| 00:00:01 |
    |*  3 |    HASH JOIN                 |                 |     1 |   655 |     2 (100)| 00:00:01 |
    |*  4 |     HASH JOIN                |                 |     1 |   625 |     2 (100)| 00:00:01 |
    |   5 |      NESTED LOOPS            |                 |     1 |   509 |     1 (100)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |*  6 |       HASH JOIN              |                 |     1 |   496 |     1 (100)| 00:00:01 |
    |   7 |        NESTED LOOPS          |                 |     1 |   428 |     1 (100)| 00:00:01 |
    |*  8 |         HASH JOIN            |                 |     1 |   138 |     1 (100)| 00:00:01 |
    |*  9 |          FIXED TABLE FULL    | X$KSUSE         |     1 |    69 |     0   (0)| 00:00:01 |
    |* 10 |          FIXED TABLE FULL    | X$KTSSO         |     1 |    69 |     0   (0)| 00:00:01 |
    |* 11 |         FIXED TABLE FULL     | X$KSPPCV        |     5 |  1450 |     0   (0)| 00:00:01 |
    |* 12 |        FIXED TABLE FULL      | X$KSPPI         |     1 |    68 |     0   (0)| 00:00:01 |
    |* 13 |       FIXED TABLE FIXED INDEX| X$KSLED (ind:2) |     1 |    13 |     0   (0)| 00:00:01 |
    |* 14 |      FIXED TABLE FULL        | X$KSUSE         |     1 |   116 |     0   (0)| 00:00:01 |
    |* 15 |     FIXED TABLE FULL         | X$KSUPR         |     1 |    30 |     0   (0)| 00:00:01 |
    |* 16 |    FIXED TABLE FIXED INDEX   | X$KSLED (ind:2) |     1 |    13 |     0   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       3 - access("S"."KSUSEPRO"="ADDR")
       4 - access("S"."ADDR"="KTSSOSES")
       6 - access("X"."INDX"="Y"."INDX")
           filter(TRANSLATE("KSPPINM",'_','#') NOT LIKE '#%' OR "KSPPSTDF"='FALSE' OR
                  BITAND("KSPPSTVF",5)>0)
       8 - access("KTSSOSES"="S"."ADDR" AND "KTSSOSNO"="S"."KSUSESER")
    PLAN_TABLE_OUTPUT
       9 - filter("S"."INST_ID"=USERENV('INSTANCE') AND BITAND("S"."KSSPAFLG",1)<>0 AND
                  BITAND("S"."KSUSEFLG",1)<>0)
      10 - filter("X$KTSSO"."INST_ID"=USERENV('INSTANCE'))
      11 - filter(NVL("KTSSOBLKS",0)*TO_NUMBER(NVL("KSPPSTVL",'0'))/1024/1024>0)
      12 - filter("KSPPINM"='db_block_size' AND "X"."INST_ID"=USERENV('INSTANCE') AND
                  TRANSLATE("KSPPINM",'_','#') NOT LIKE '##%')
      13 - filter("S"."KSUSEOPC"="E"."INDX")
      14 - filter("S"."INST_ID"=USERENV('INSTANCE') AND BITAND("S"."KSSPAFLG",1)<>0 AND
                  BITAND("S"."KSUSEFLG",1)<>0)
      15 - filter("INST_ID"=USERENV('INSTANCE') AND BITAND("KSSPAFLG",1)<>0)
      16 - filter("S"."KSUSEOPC"="E"."INDX")
    44 rows selected.

    Actually I can reproduce, when hardcoding block size the query runs ok, but the other version keeps on ending up in an error:
    SQL>   select a.username,
      2           a.sid, a.serial#,
      3           (b.blocks * 8192)/1024/1024 size_mb,
      4           a.status,
      5           b.segfile#,
      6           b.segblk#
      7    from v$session a,
      8         v$sort_usage b,
      9         v$process c
    10    where a.saddr = b.session_addr
    11      and a.paddr = c.addr
    12      and (b.blocks * 8192)/1024/1024 > 0;
    USERNAME                              SID    SERIAL#    SIZE_MB STATUS     SEGFILE#    SEGBLK#
    *********                             254       6958          1 INACTIVE        201      33280
    *********                             254       6958          1 INACTIVE        201      33664
    2 rows selected.
    SQL>  with q as (
      2    select v$parameter.value bs_value
      3    from v$parameter
      4    where name='db_block_size'
      5  )
      6  select a.username,
      7         a.sid, a.serial#,
      8         round(((b.blocks*bs_value)/1024/1024),2) size_mb,
      9         a.status,
    10         b.segfile#,
    11         b.segblk#
    12  from v$session a,
    13       v$sort_usage b,
    14       v$process c,
    15       q
    16  where a.saddr = b.session_addr
    17    and a.paddr = c.addr
    18    and ((nvl(b.blocks,0)*nvl(bs_value,0))/1024/1024) > 0;
      and ((nvl(b.blocks,0)*nvl(bs_value,0))/1024/1024) > 0
    ERROR at line 18:
    ORA-01722: invalid number
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      ProductionNow I've been fiddling with the query, adding to_number, omitting nvl etc. etc., but I keep on getting invalid number,. no matter what...
    This is either very weird or I'm missing something very obvious here.. ?:|

  • To_number and scientific notation

    Hi
    I am trying to convert a number in scientific notation stored in a character ffield to a number.
    I use this statement, but gets a ORA-01722 error.
    What is wrong ?
    select to_number('1.1111111111111112E-6','9.9EEEE')
    from dual
    Preben

    Hi guys, I'm following this forum in order to reuse what you wrote, but I still have a problem with the scientific notation format...
    From SQL Plus If I run this query:
    select b.CONTRACT_NUMBER,b.id as cont_id from OKC_K_HEADERS_B b--, okc_k_lines_b v
    where b.contract_number = 'NR19Mini'
    I retrieve the following row:
    CONTRACT_NUMBER                       CONT_ID
    NR19Mini                           1.4733E+38where the CONT_ID datatype is NUMBER.
    Now I want to specify a condition using the CONT_ID field (for another use in the future), but if I use the following syntax
    select b.CONTRACT_NUMBER,b.id as cont_id from OKC_K_HEADERS_B b
    where b.contract_number = 'NR19Mini'
    and b.id = to_number('1.4733E+38','9.99999EEEE');
    I don't retrieve any rows (no rows selected)
    How can I modify the format number in order to see my row, and for example use it inside a join with another fied of the same type ?
    Thanks in advance
    Alex

  • How to override to_number function?!

    Hi,
    I already tried to find an answer by searching this forum but without success...
    My problem is, that I have a lot of mappings using the to_number() function to convert char into number. Now it turns out, that in some cases - due to the bad data qualtity - fields contain special chars e.g. 1234" Don't ask why ;) Of course the reguIar tu_number() function fails on that. Now I wrote a to_number function that handles the issue by removing all the special chars and then convert. I now want to override oracle's built-in to_number function with my own function.
    Do you have any ideas how that works? As a requirement the solution should be simple... It would be an imense work to edit every mapping. I global solution is preferred. Something like a priority option, to take self written functions first or sth...
    Thanks for any help!
    Cheers Steffen

    Hi,
    you could use OMB to change all occurance of that functino in your project.
    Unfortunately I know OWB allmost only from theory :-( but I remember, that you can set a context to a project or a mapping and all subsequent operations will happen within that horizont.
    As far as I saw, OMB isn't to hard to use, even without days of learning, just by looking for fitting operation, but I know documentation about OMB is pretty poor, almost only syntax reference is available.
    really overriding the pre_build to_number-function might be possible as sys, but I would avoid that or only do in a relly play-instance. I suppose you tried allready simply to run 'create or replace ...' ?
    Thanks for your tip about number checking, but I tried allready many variations functions like that. I never can get it validated:
    I have a function is_number_num, returning 1 for ok, 0 for false, which si working fine on SQL*PLUS, but when I use it splitter-condition, in this variations:
    "IS_NUMBER_NUM"( GRP_IN.ANZAHL,'NLS_NUMERIC_CHARACTERS='',.''') = 1
    I get: PLS-00801 internal error [phdxcsql_canonicalize_sql:state]
    with .... == 1
    I get:
    Line 0, Col 0:
    The expression is not properly formed.
    I have no bloody idea, what that means and what might be wrong in here ? Even google does not return 1 singel page for the error-parameter !
    I tried several versions:
    "IS_NUMBER_NUM"( GRP_IN.ANZAHL,'NLS_NUMERIC_CHARACTERS='',.''') = 1
    also this: "IS_NUMBER_NUM"( GRP_IN.ANZAHL) = 1
    but nothing is accepted !
    Also I made a more easy function for checking for date-format, which works fine in SQL*PLUS, but can't be validated in OWB-splitter.
    Oracle support is playing for time since days !
    thsi function brings same error, depending if I use 1 or 2 "=" !???
    any idea ?
    somehow I have the feeling, I missed 1 easy rule on how to use a splitter-condition correctly ?
    But I can't see anything wrong in my constructions, especially because they are working fine in SQL*PLUS !???
    thanks for any hint, LaoDe

  • Error in converting to To_number

    i'm using an employee table in which the phone number is stored as a character.. eg: 515.123.4567. i want to extract the last 8 numbers and convert it into a number format..
    i user the following query..
    select substr(phone_number,-8) from employees
    and
    select to_number(substr(phone_number,-8),'999.9999')*10000 Local_number from employees -- if i use this it says that ORA-01722 invalid number error..
    but the following query
    select to_number(substr(phone_number,-8),'999.9999')*10000 local_numbe from employees where department_id<=50 is working properly
    but if i gve
    select to_number(substr(phone_number,-8),'999.9999')*10000 local_numbe from employees where department_id<=150 --it throwing the same error, though dept 150 is nt thre in my table it should display the lesser, right?
    'm using 9i database and in toad i executed these queries
    regards renji

    If I understand your problem, you are asking if you should get results even when you don't have deptno's upto 150?
    SQL> select *
      2    from emp
      3   where deptno <= 150
      4  /
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.I don't have deptno 150, and I'm getting all records back.
    The error is coming from the phone-number conversion to a NUMBER. Why do you want to change it to a NUMBER anyway, can't you just leave it a VARCHAR2?

  • Subquery, TO_NUMBER and ORA-01722 invalid number

    I'm running into a invalid number error (ORA-01722) when I expect none.
    I have a table that stores a semester term as a VARCHAR2, all term codes are actually numbers like 200609. There is one exception which I filter out, using a subquery, to prevent the invalid number error.
    My query looks like this:
    SELECT NVL(SUM(s.balance))
    FROM (SELECT s1.term, s1.balance
    FROM student_account s1
    WHERE s1.student_id = :student_id
    AND s1.term <> 'SCRIPT') s
    WHERE TO_NUMBER(s.term) <= 200609;
    The query errors with ORA-01722.
    Now I've checked and rechecked that there isn't another bad term that is not a number.
    SELECT DISTINCT '[' || term || ']'
    FROM student_account
    WHERE student_id = :student_id;
    The error complains at line of the WHERE clause.
    I've ran just the subquery and changed the column list to select distinct term. All terms are numbers. I think that the outer WHERE clause for some reason still gets the 'SCRIPT' term. Though I've tried to verify this with no luck.
    I created a function that simply takes the term writes it to DBMS_OUTPUT and returns it as a VARCHAR2. The weird thing is then the query works. For example the outer WHERE clause becomes: WHERE TO_NUMBER(PRINT_TERM(s.term)) <= 200609
    I've also tried to move the TO_NUMBER to the subquery without any luck, same error.
    Anyone know what is going on?

    Oracle is allowed to push predicates into the subquery, so there is no guarantee that the problem row is filtered out before TO_NUMBER is called. You can get into some very interesting discussions about whether this is the right behavior from a relational theory and/or ANSI standard perspective, but you're probably stuck with the behavior (unless you want to get Oracle to rework their optimizer)
    One way to get around the problem would be to write a my_to_number function that catches the error and returns NULL if the to_number conversion fails, i.e.
    CREATE FUNCTION my_to_number( p_num IN VARCHAR2 )
      RETURN NUMBER
    IS
      l_num number;
    BEGIN
      l_num := to_number( p_num );
      RETURN l_num;
    EXCEPTION
      WHEN <<Exception whose name escapes me>> THEN
        RETURN NULL;
    END;And use that in your query.
    Justin
    Message was edited by:
    Justin Cave

  • TO_NUMBER and ORA-01722 invalid number pls delete

    I cannot see where to delete a post I made. I found out my problem. It was in my NLS settings. Decimals were set to be commas instead of periods.
    please disregard this post, and delete if you are a moderator
    I recently tried to bring in lat/long coordinates from a VARCHAR2 field (and even as a flat file) into a NUMBER field with a setup of NUMBER(20,13) to ensure I'd capture all of the signifigant digits.
    I even ran this through a procedure to check if the data is a number first, and update only. I've found however that I keep getting the ORA-01722 invalid number error.
    So I started testing out some points, and came across this:
    select to_number('-79.662965387') from dual;
    this query results in the invalid number error. I don't want to have to load these as an SDO GEOMETRY object, has anyone encountered this scenario before?
    Or is my choice of 13 decimal places too high for Oracle?

    I just ran that code in my database (10g) and it returned this
    select to_number('-79.662965387') from dual;
    TO_NUMBER('-79.662965387')
                    -79.662965
    1 row selected.Message was edited by:
    Tridith

  • To_number with period and comma

    As a part of a validation function I have to validate strings against a valid number format. The following weird behaviour I have spot during the implementation.
    SQL> select TO_NUMBER('1.1.1.1,11','9G999D99') from dual;
    TO_NUMBER('1.1.1.1,11','9G999D99')
    1111,11
    SQL> select TO_NUMBER('1.1.11,11','9G999D99') from dual;
    TO_NUMBER('1.1.11,11','9G999D99')
    1111,11
    SQL> select TO_NUMBER('1.111,11','9G999D99') from dual;
    TO_NUMBER('1.111,11','9G999D99')
    1111,11
    SQL> select TO_NUMBER('1111,11','9G999D99') from dual;
    select TO_NUMBER('1111,11','9G999D99') from dual
    FEHLER in Zeile 1:
    ORA-01722: Ungltige Zahl
    '1.111,11' should be valid only. Is it a bug or my misconception?
    These statements ran on Release 11.1.0.6.0.

    Sorry, I've I forgot to mention that my nls_numeric_characters parameter is set to ',.' already.
    SQL> select VALUE from NLS_SESSION_PARAMETERS where PARAMETER='NLS_NUMERIC_CHARACTERS';
    VALUE
    Anyway, with the nls_numeric_character parameter passed to the function these statements did not produce any error.
    SQL> select TO_NUMBER('1.1.1.1,11','9G999D99','nls_numeric_characters=,.') from dual;
    TO_NUMBER('1.1.1.1,11','9G999D99','NLS_NUMERIC_CHARACTERS=,.')
    1111,11
    SQL> select TO_NUMBER('1.1.11,11','9G999D99','nls_numeric_characters=,.') from dual;
    TO_NUMBER('1.1.11,11','9G999D99','NLS_NUMERIC_CHARACTERS=,.')
    1111,11
    I except an error to be thrown. Obviously both numbers '1.1.1.1,11' and '1.1.11,11' did not match the mask '9G999D99'.

  • To_Number conversion in Fast Formula

    Hi All
    I am doing a simple Fast Formula calculation where I'm trying to convert the return date into number.
    It is throwing error. But What am i doing wrong. I'm trying to convert the date returned value to number.
    APP-FF-33983: Parameter type mismatch for function 'TO_NUMBER' at line 15
    Cause: The user has specified a function whose name has been recognised but whose parameter types do not match any known version of the function.
    Action: Please check that any variables or literals passed to the function are of the appropriate types for the function definition. ***
    This is my code
    DEFAULT FOR EMP_TERM_DATE IS '1-JAN-4712'(date)
    DEFAULT FOR PAY_PROC_PERIOD_START_DATE IS '01-JAN-1951' (date)
    DEFAULT FOR PAY_PROC_PERIOD_END_DATE IS '31-DEC-4712' (date)
    DEFAULT FOR C_Allowance_Balance_ASG_YTD is 0
    DEFAULT FOR L_paid_amount IS 0
    DEFAULT FOR Day_amount IS 0
    DEFAULT FOR days_deduction IS 0
    DEFAULT FOR deducted_amount IS 0
    DEFAULT FOR L_last_day is '31-JAN-4712'(date)
    L_last_day = TO_DATE( '31-DEC-'+TO_CHAR(PAY_PROC_PERIOD_END_DATE,'YYYY'),'DD-MON-YYYY')
    Day_amount = (C_Allowance_Balance_ASG_YTD)/ 365
    /**15* */ days_deduction =to_number(l_last_day- EMP_TERM_DATE)
    deducted_amount = days_deduction*days_amount
    return deducted_amount

    Thanks Avinash,for the reply!
    Tried that also...
    this is the error i get.
    APP-FF-33003: Line 18: 'DAYS_DEDUCTION' is of type NUMBER but has DATE type assigned into it.
    Cause: The data type of the expression on the right hand side of the assignment statement does not match the data type of the variable on the left hand side of the assignment, probably because of an earlier assignment to the variable of a different data type.
    Action: Ensure data types of assignments match, or that variable being set has not been set before to another data type.
    This is my complete formula
    DEFAULT FOR EMP_TERM_DATE IS '1-JAN-4712'(date)
    DEFAULT FOR PAY_PROC_PERIOD_START_DATE IS '01-JAN-1951' (date)
    DEFAULT FOR PAY_PROC_PERIOD_END_DATE IS '31-DEC-4712' (date)
    DEFAULT FOR C_Allowance_Balance_ASG_YTD is 0
    DEFAULT FOR L_paid_amount IS 0
    DEFAULT FOR Day_amount IS 0
    DEFAULT FOR days_deduction IS 0
    DEFAULT FOR deducted_amount IS 0
    DEFAULT FOR L_last_day is '31-JAN-4712'(date)
    L_msg = 'Club Allowance: '
    L_last_day = TO_DATE( '31-DEC-'+TO_CHAR(PAY_PROC_PERIOD_END_DATE,'YYYY'),'DD-MON-YYYY')
    Day_amount = (C_Allowance_Balance_ASG_YTD)/ 365
    days_deduction = L_last_day-EMP_TERM_DATE
    deducted_amount = (days_deduction*day_amount)
    L_msg = L_msg||' Term Date :'||to_char(EMP_TERM_DATE)||'Days_ded: '||to_char(days_deduction)
    return deducted_amount,L_msg

  • To_number conversion error in OWB runtime

    I have a mapping in OWB 10.1.0.5 that does something like that :
    select t1.a_field,to_number(t2.a_stringField)
    from a_table t1
    an_other_table@source_schemas@source_database t2
    where (....)
    the t2.a_stringField may contain:
    '1256'
    '5'
    '12'
    '5,8'
    when I run my mapping from SQL_PLUS
    begin
    my_mapping.main();
    end;
    it works well,
    but when I run my mapping with OWB, my mapping terminates with errors on the line containing a decimal value (the line with coma decimal separator).
    I deployed my mapping over three similar database (developpement,test,production) and the problem appends for just one of them !
    any idea ?
    these are my database parameter :
    NLS_TERRITORY     AMERICA
    NLS_NUMERIC_CHARACTERS '.,'
    the paramters for the current user (target schemas):
    NLS_TERRITORY     FRANCE
    NLS_NUMERIC_CHARACTERS ',.'
    my 'source_database' parameters :
    NLS_TERRITORY     AMERICA
    NLS_NUMERIC_CHARACTERS '.,'
    and the parameters for the user 'source_schemas' :
    NLS_TERRITORY     FRANCE
    NLS_NUMERIC_CHARACTERS ',.'

    Hi Jean,
    I think you need to change NLS_LANG to the same value as on your other two servers (and don't forget to restart OWB runtime).
    Or you can specify nls parameter in TO_NUMBER function:
    TO_NUMBER('9,5','999D99', 'NLS_NUMERIC_CHARACTERS = '', ''')
    Regards,
    Oleg

  • Using to_number in a where clause

    Consider a table T that has 2 columns, of type VARCHAR2. Consider the following tables values
    Col1 Col2
    A        1
    A        2
    B        X
    B        Y
    will the below query always work:
    select * from T where col1 = 'A' and to_number(col2) between 1 and 2
    Would oracle apply the where clause criteria as defined in the SQL from left to right?
    Thanks
    Aspi Engineer
    Edited by: aengineer on Jun 22, 2010 8:52 AM

    Adding the rownum worked.
    Explain plan before adding rownum:
    | Id  | Operation                   | Name                | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |                     |     1 |    75 |  2762   (1)| 00:00:39 |
    |*  1 |  TABLE ACCESS BY INDEX ROWID| MMS_MESSAGE_INFO    |     1 |    75 |  2762   (1)| 00:00:39 |
    |*  2 |   INDEX RANGE SCAN          | MMS_MESSAGE_INFO_N2 | 12845 |       |    18   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("MESSAGE_SUBJECT" LIKE 'VALUE%' AND TO_NUMBER("MESSAGE_RVSEQUENCE")>=1 AND
                  TO_NUMBER("MESSAGE_RVSEQUENCE")<=29 AND "REALM_ID"=30)
       2 - access("MESSAGE_DATE">=TO_DATE(' 2010-06-21 09:40:00', 'syyyy-mm-dd hh24:mi:ss')
                  AND "MESSAGE_DATE"<=TO_DATE(' 2010-06-21 12:10:00', 'syyyy-mm-dd hh24:mi:ss'))Explain Plan after adding rownum:
    | Id  | Operation                     | Name                | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT              |                     |     1 |   140 |  2762   (1)| 00:00:39 |
    |*  1 |  VIEW                         |                     |     1 |   140 |  2762   (1)| 00:00:39 |
    |   2 |   COUNT                       |                     |       |       |            |          |
    |*  3 |    TABLE ACCESS BY INDEX ROWID| MMS_MESSAGE_INFO    |     1 |    75 |  2762   (1)| 00:00:39 |
    |*  4 |     INDEX RANGE SCAN          | MMS_MESSAGE_INFO_N2 | 12845 |       |    18   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter(TO_NUMBER("T"."MESSAGE_RVSEQUENCE")<=29 AND
                  TO_NUMBER("T"."MESSAGE_RVSEQUENCE")>=1)
       3 - filter("MESSAGE_SUBJECT" LIKE 'VALUE%' AND "REALM_ID"=30)
       4 - access("MESSAGE_DATE">=TO_DATE(' 2010-06-21 09:40:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "MESSAGE_DATE"<=TO_DATE(' 2010-06-21 12:10:00', 'syyyy-mm-dd hh24:mi:ss'))Can you help explain why did it work, and would this always work?
    Thanks

  • How to use floor(to_number(substr x))) in where clause???

    Hi,
    I have a column doc_id which value like abcd.01.023. If I
    select floor(to_number(substr(doc_id, instr(doc_id, '.', 1)+1, instr(doc_id, '.', 1)+1 )))
    it works,
    but get ORA-01722: invalid number if I use in where clause like:
    Where floor(to_number(substr(doc_id, instr(doc_id, '.', 1)+1, instr(doc_id, '.', 1)+1 ))) =0
    Could you tell me how to fix?
    Thansk

    My guess is that you didn't process the same rows with each query. Maybe you have some where conditions on the 'select' query that filters out the offending rows. If the doc_id value could not be converted to a number is should raise the error in either case.
    Besides that, your substring looks wrong to me. Why take "instr(doc_id, '.', 1)+1" characters? Why not just:
    floor(substr(doc_id, instr(doc_id, '.') + 1))
    Even then, the portion after the first '.' must be a valid number.
    Richard

  • Issue with To_number when we submit Shipping report from Document set

    Hi All
    We have a report in Shipping responsibility which works fine when we submit from Standard Request form, when we submit through Document set we are getting error
    as Invalid Number for to_number conversion in formula columns which is ok from sql developer
    begin
    select to_number(rtrim(ltrim(nvl(attribute6 ,'0') ))) ---decode(weight_uom_code,'LB', gross_weight * .4536, gross_weight)
    into v_gross_weight
    from wsh_new_deliveries
    where delivery_id = :pick_slip_number;
    Any hints for fixing this will be helpfull
    Thanks
    Kamalakar.G

    Hi
    When used this where delivery_id = to_number(:pick_slip_number); it worked
    As same rdf file is used by 2 Concurrent Programs it worked for One program for other program it gave error Invalid Number ORA-01722: invalid number
    select to_number(rtrim(ltrim(nvl(attribute6 ,'0') ))) ---decode(weight_uom_code,'LB', gross_weight * .4536, gross_weight)
    into v_gross_weight
    from wsh_new_deliveries
    where delivery_id = to_number(:pick_slip_number);
    Thanks
    Kamalakar G

  • To_number gives error in one DB pl/sql program and not in other DB

    Hi,
    We have the following issue.. In some pl/sql code there is a statement
    l_number := to_number(pio_value);
    This results in DB-A in an error - invalid number.. in DB-B this codes works..
    If in DB-A the NLS setting is changed
    EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ''.,''';
    l_number := to_number(pio_value);
    the code works also..
    I assume this error has to do with difference in NLS settings.. However I cannot find any of those differences in the database NLS settings..
    Are there other settings which can cause this behaviour?
    regards, Richard

    RichardK2 wrote:
    Hi,
    We have the following issue.. In some pl/sql code there is a statement
    l_number := to_number(pio_value);
    This results in DB-A in an error - invalid number.. in DB-B this codes works..
    If in DB-A the NLS setting is changed
    EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ''.,''';
    l_number := to_number(pio_value);
    the code works also..
    I assume this error has to do with difference in NLS settings.. However I cannot find any of those differences in the database NLS settings..
    Are there other settings which can cause this behaviour?not data presentation settings; but data dependent error.
    Error is thrown when variable PIO_VALUE contains non-numeric character

Maybe you are looking for

  • Section 80C deductions

    Hi Experts I need your help The client I am working for requires a report that will give break up ofthe Section 80 C deductions Example: Section 80C                Premium paid for life insurance                Payment for deferred annuity           

  • Strange issue - unable to establish PPP with Cisco 887 VAG router on one particular ADSL line

    I have a strange problem that I’m struggling to get to the bottom of with my ISP and wondered if anyone could help. We have a site with an older Cisco 877 ADSL router which was working happily until a few weeks ago when the connection dropped suddenl

  • Mountain Lion Trouble with my mini

    I'm trying to install ML on my late 2009 mac mini, but during the install it said my drive had some corrupt files.  I ran a verify disk wich found the following: Incorrect number of thread records Incorrect number of extended attributes The volume Ma

  • Restoring old text messages

    How do I find old messages? Like from 7 months ago

  • Wow. Applauses for the Skype Support. (Account Blo...

    Dear Sirs, I come with a complaint. Skype has completely BLOCKED/SUSPENDED without any kind of explanation leaving me at a loss as to why.  I cannot believe what I am having to go through to get help with my account that has been blocked. I have no i