Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-00904: invalid identifier

987522Sep 5 2013 — edited Sep 6 2013

Hi,

I recently asked on here about creating my first stored procedure, it compiled fine, but unfortunately whilst trying to run it I get this error:

Retrieve Error:ORA-00904: "V_URN": invalid identifier

ORA-06512: at "CONTACT_RETURN", line 23

ORA-06512: at line 1

Here's my stored procedure:

CREATE OR REPLACE

procedure contact_return(

    v_urn IN number,

    p_cursor OUT SYS_REFCURSOR )

AS

  sql_statement VARCHAR2(4000) := '      

  SELECT URN,

    FIRSTNAME,

    LASTNAME,

    TITLE,

    CREATED_DT,

    AREA_URN,

    MOBILE,

    WORK,

    EMAIL,

    ORG_NAME,

    ADDRESS,

    POSTCODE,

    IN_USE

  FROM CONTACT

  WHERE urn = NVL(:1,v_urn)';

BEGIN

  OPEN p_cursor FOR sql_statement USING v_urn;

end;

I cannot see a problem with it, since v_urn is declared at the top in the brackets.

Does anyone please have any idea why I'm getting this error? I'm at a loss!

Thanks

This post has been answered by John Spencer on Sep 5 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 4 2013
Added on Sep 5 2013
21 comments
4,313 views