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!

Unable to use date format in EXECUTE IMMEDIATE

user11334489Jul 27 2023 — edited Jul 27 2023

Hi All,

Unable to use date format in EXECUTE IMMEDIATE.

DECLARE
v_date DATE;
BEGIN
v_date := TO_DATE('20-01-1981','DD-MM-YYYY');
EXECUTE IMMEDIATE 'create table test_emp as select * from emp where TRUNC(HIREDATE)>= ' || v_date;
END;

Getting below error while executing the above script.

Error report -
ORA-00932: inconsistent datatypes: expected DATE got NUMBER
ORA-06512: at line 5
00932. 00000 - "inconsistent datatypes: expected %s got %s"
*Cause:
*Action:

How to solve it.

I am using Oracle Database 19c.

Thanks in advance.

Best Regards,

Abu

Comments
Post Details
Added on Jul 27 2023
4 comments
1,131 views