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!

Concatenation of EXECUTE IMMEDIATE statement.

DaveyBFeb 23 2012 — edited Feb 23 2012
Hi All,

The situation is that I am trying to find all customers whose Date Of Birth (DOB) is greater or equal to 150 days ago. Unfortunately, when I run this SQL I get these error message:
1) ORA-00904: "FEB": invalid identifier
1) ORA-06512: at line 4

I am unsure what I need to do to resolve this, I hope you can help.

Note - I have to wrap this statement in an execute immediate due to Roles/Privilidge issues. In the full version I also use AUTHID CURRENT_USER.


DECLARE
    curr_date Date := SYSDATE;
BEGIN
    EXECUTE IMMEDIATE ' SELECT  cust_name,
                                cust_dob, -- date of birth
                                cust_shoe_size
                        FROM    tblCustDetails c
                        WHERE   SUBSTR(c.cust_name, 1,7) = ''Bob''
                                AND cust_dob >= NEXT_DAY(' || curr_date ||' - 150 , ''SATURDAY'')
                         ';
END;
Edited by: DaveyB on Feb 23, 2012 8:39 AM
This post has been answered by BluShadow on Feb 23 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 22 2012
Added on Feb 23 2012
9 comments
1,538 views