Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5990877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:18:25+00:00 2026-05-22T23:18:25+00:00

i wanna be able to execute my below proc like so: exec procname(’29-JAN-2011′); proc

  • 0

i wanna be able to execute my below proc like so:

exec procname('29-JAN-2011');

proc code is:

PROCEDURE procname(pardate VARCHAR2) IS

  vardate DATE := to_date(pardate, 'DD-MON-YYYY');
  SQLS VARCHAR2(4000);

BEGIN    

  SQLS := 'SELECT cola, colb
             FROM tablea 
            WHERE TRUNC(coldate) = TRUNC(TO_DATE('''||pardate||''',''DD/MON/YYYY''))';

  EXECUTE IMMEDIATE SQLS;

END;

It keeps throwing error:

ORA-00904: “JAN”: invalid identifier.

It compiles, but it throws the error when I run this command:

EXEC procname('29-JAN-2011');
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:18:26+00:00Added an answer on May 22, 2026 at 11:18 pm

    You declare a variable which casts the input parameter to a date: why not use it?

    Also, the TRUNC() applied to a date removes the time element. You don’t need it here because the value you’re passing has no time.

    So, your code should be:

    PROCEDURE procname(pardate VARCHAR2) IS
    
      vardate DATE := to_date(pardate, 'DD-MON-YYYY');
      SQLS VARCHAR2(4000)  := 'select cola, colb FROM tablea 
               WHERE TRUNC(coldate) = :1';
    
       l_a tablea.cola%type;
       l_b tablea.colb%type;
    BEGIN    
      EXECUTE IMMEDIATE SQLS 
          into l_a, l_b
          using vardate;
    END;  
    

    Specifying the dynamic SQL statement with a bind variable and executing it with the USING syntax is a lot more efficient. Note that we still have to SELECT into some variables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI I wanna timeout session from client page,i tried below code but not able
I have a popup confirm box which i am able to show like below.
I wanna do something like the safari app when fill a form, so when
I wanna rewrite links like index.php?page=entry&id=15&action=edit to entry/15/edit . This is how my .htaccess
i wanna disable a submit button when onclick. im able to disable the button
I wanna know a corresponding method in Android/Java that is like the GetTickCount method
I wanna launch the Contacts application from my application Activity. I am not able
Wanna write a RegEx to validate a driving license. if it doesn't start with
I wanna get the Timedate value from another page using request.querystring and then use
I wanna stop the reading of my text input file when the word synonyms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.