简体   繁体   中英

Quote issue during execute immediate

Getting error for syntax for the execute immediate

select distinct hire_date BULK COLLECT into v_yr from employees;
 
 for i in 1..v_yr.count LOOP
 

   
 v_1:='select * from employees where EXTRACT(YEAR FROM TO_DATE(HIRE_DATE,'''
    ||DD-MM-RR
||'''
||'=:1';

     open c_emp for v_1 using v_yr(i);

Maybe this?

select distinct extract(year from hire_date)
  bulk collect into v_yr
  from employees;
 
for i in 1..v_yr.count loop

   for c_emp in (select *
                   from employees
                  where extract(year from hire_date) = v_yr(i)) loop
.
.
.
   end loop;

end for;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM