invalid column name in SQL query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • josna
    New Member
    • Aug 2007
    • 1

    invalid column name in SQL query

    I am trying to execute following query but i am getting a sql exception
    i do not understand where i went wrong. it is saying invalid column name but i have given all fields and table names correctly, please help me out.

    java.sql.SQLExc eption: ORA-00904: invalid column name


    [CODE=java] rs=st.executeQu ery("SELECT EP.EMP_ID,EP.EM P_PASS,EC.CNAME ,EC.MEMAIL,EC.T YPE,EC.CPERSON, EC.DESIG,EC.WUR L,EC.EADDR,EC.E CITY,EC.ESTATE, EC.EZIPCODE,EC. ECOUNTRY,EC.EMB NO,EC.PHNO,EC.F AXNO FROM EMP_LOGIN EP,EMP_COMPANY_ DETAILS EC WHERE (EP.EMP_ID='"+t his.empid+"'AND EP.EMP_PASS='"+ this.epwd+"'AND EP.EMP_ID=EC.EM P_ID)");[/CODE]

    if any one knows solutuion. please mail me at xxxxxxxx@xxxxxx xx.xxx

    thank you
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Sorry, no email addresses allowed as per the posting guidelines.

    The SQL parser isn't wrong: you're definitely passing an incorrect column name
    in that query. Not knowing what the correct names are I can't help you out any
    further; you have to meticulously check every single column name and check
    whether or not you have inserted spaces and/or commas at the right places as well.

    kind regards,

    Jos

    Comment

    • praveen2gupta
      New Member
      • May 2007
      • 200

      #3
      Originally posted by josna
      I am trying to execute following query but i am getting a sql exception
      i do not understand where i went wrong. it is saying invalid column name but i have given all fields and table names correctly, please help me out.

      java.sql.SQLExc eption: ORA-00904: invalid column name


      [CODE=java] rs=st.executeQu ery("SELECT EP.EMP_ID,EP.EM P_PASS,EC.CNAME ,EC.MEMAIL,EC.T YPE,EC.CPERSON, EC.DESIG,EC.WUR L,EC.EADDR,EC.E CITY,EC.ESTATE, EC.EZIPCODE,EC. ECOUNTRY,EC.EMB NO,EC.PHNO,EC.F AXNO FROM EMP_LOGIN EP,EMP_COMPANY_ DETAILS EC WHERE (EP.EMP_ID='"+t his.empid+"'AND EP.EMP_PASS='"+ this.epwd+"'AND EP.EMP_ID=EC.EM P_ID)");[/CODE]

      if any one knows solutuion. please mail me at xxxxxxxx@xxxxxx xx.xxx

      thank you

      Hi

      I am not able to understand why you are using this keyword. This keyword will not work here. Remove it and test. If still there is error then post complete code.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by praveen2gupta
        Hi

        I am not able to understand why you are using this keyword. This keyword will not work here. Remove it and test. If still there is error then post complete code.
        It might work if 'epwd' and 'empid' are members of the object itself. The 'this'
        reference would be redundant but it would work fine.

        kind regards,

        Jos

        Comment

        Working...