locked
ORA-01722: invalid number RRS feed

  • Question

  • User1156251743 posted

    Hi Friends,

         When iam trying to access database by using query "select ename from "+s1+" where eno="+s2(s1 and s2. s1=emp; s2=1205-->see in below code image) it gives error even the query is correct. It works perfectly when "eno" changes to some number instead of "jyfuy". i'm also posing images given below

    Code Image

                                                                            This is Code Image

    Emp Table

    <-----Emp Table

    Error

                                                                                                      Error

    Even if I use query "select ename from "+s1+" where eno="+s2(s1=emp;s2=jyfuy),It gives error like this (given below)


    Only it gives correct Output when I replace "jyfuy" with some number in Oracle 10g Database.

    Plz Help me......


    Saturday, July 21, 2012 6:44 AM

Answers

  • User1983487377 posted

    select ename from "+s1+" where eno="+s2

    your Query should be like this

    "select ename from "+s1+" where eno='"+s2 + "'"


    all the best

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 21, 2012 7:16 AM
  • User1983487377 posted

    So, what is reason???

     

    Yes, to compare with alphanumeric (varchar) datatype you must wrap the value with single quote('), for numeric its not necessory.

    here your table contains  alphanumeric values so it should be compared with single quote.

    however, single quote will also work with numeric values as alphanumerics.

    Hope this help you. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 22, 2012 2:04 AM

All replies

  • User1983487377 posted

    select ename from "+s1+" where eno="+s2

    your Query should be like this

    "select ename from "+s1+" where eno='"+s2 + "'"


    all the best

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 21, 2012 7:16 AM
  • User1156251743 posted

    It works,,

    Thank You Very much Bhaarat...Smile

    Saturday, July 21, 2012 8:20 AM
  • User1156251743 posted

    But Bhaarat,

          My query("select ename from "+s1+" where eno="+s2) Works perfectly, if "jyfuy" is replaced with 1200(any number) like this...

    So, what is reason???

    Saturday, July 21, 2012 8:46 AM
  • User1983487377 posted

    So, what is reason???

     

    Yes, to compare with alphanumeric (varchar) datatype you must wrap the value with single quote('), for numeric its not necessory.

    here your table contains  alphanumeric values so it should be compared with single quote.

    however, single quote will also work with numeric values as alphanumerics.

    Hope this help you. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 22, 2012 2:04 AM
  • User1156251743 posted

    Ok, i got it

       Once again thank you very much....Smile

    Sunday, July 22, 2012 5:45 AM