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-00900: invalid SQL statement when doing execute immediate using .

698658Jun 21 2012 — edited Jun 21 2012
Hi,
I'm writing simple code db is 9.2.0.8
create or replace procedure gather_part_stats(p_schema in varchar2, p_table in varchar2)
as
l_quarter varchar2(8) := to_char(sysdate, '"Y"YYYY"_Q"q') ;
l_sql varchar2(2000) := 'exec dbms_stats.gather_table_stats(:schema, :table, method_opt => ''for all columns size 1'' , cascade => true , estimate_percent => 1 , granularity => ''PARTITION'', partname=>:part);';
begin
dbms_output.put_line('l_quarter: ' || l_quarter);
dbms_output.put_line(l_sql);
execute immediate l_sql using in p_schema, in p_table, in l_quarter ;
end;
/
Trying to gather table stats with selected partition but mess up something with ... something :)
I'm using using to avoid sql injection, please advice .

Error is:
SQL> exec gather_part_stats('TEST' , 'TEST');
l_quarter: Y2012_Q2
exec dbms_stats.gather_table_stats(:schema, :table, method_opt => 'for all columns size 1' , cascade => true , estimate_percent => 1 , granularity => 'PARTITION', partname=>:part);
BEGIN gather_part_stats('TEST' , 'TEST'); END;

*
ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at "INSTALL.GATHER_PART_STATS", line 8
ORA-06512: at line 1

Regards
GregG
This post has been answered by jeneesh on Jun 21 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 19 2012
Added on Jun 21 2012
12 comments
8,370 views