dbTalk Databases Forums  

using EXECUTE IMMEDIATE to run DBMS_STATS.GATHER_SCHEMA_STATS

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss using EXECUTE IMMEDIATE to run DBMS_STATS.GATHER_SCHEMA_STATS in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
ddf
 
Posts: n/a

Default Re: using EXECUTE IMMEDIATE to run DBMS_STATS.GATHER_SCHEMA_STATS - 10-31-2008 , 11:52 AM






On Oct 31, 6:53*am, Kevin S <Sear... (AT) googlemail (DOT) com> wrote:
Quote:
When I run the block below, in oracle 10.2.0.3.0, I get the error
shown after. Is this a problem with my coding or is it just not
possible to run this commad in pl/sql?

Thanks

DECLARE
* * v_dbms_stats * *VARCHAR2(200):= 'EXEC
DBMS_STATS.GATHER_SCHEMA_STATS( ownname *=> ''LOAD'',
estimate_percent => 100, cascade => *TRUE,options => ''GATHER
AUTO'');';
BEGIN
* *EXECUTE IMMEDIATE *v_dbms_stats;
END;

ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at line 4
Why are you using EXECUTE IMMEDIATE to run a PL/SQL packaged procedure
from within PL/SQL when this works:

BEGIN
DBMS_STATS.GATHER_SCHEMA_STATS( ownname => 'LOAD',
estimate_percent => 100, cascade => TRUE,options => 'GATHER AUTO');
END;
/

Can you enlighten us as to why you think this exercise is absolutely
necessary?


David Fitzjarrell


Reply With Quote
  #12  
Old   
ddf
 
Posts: n/a

Default Re: using EXECUTE IMMEDIATE to run DBMS_STATS.GATHER_SCHEMA_STATS - 10-31-2008 , 11:52 AM






On Oct 31, 6:53*am, Kevin S <Sear... (AT) googlemail (DOT) com> wrote:
Quote:
When I run the block below, in oracle 10.2.0.3.0, I get the error
shown after. Is this a problem with my coding or is it just not
possible to run this commad in pl/sql?

Thanks

DECLARE
* * v_dbms_stats * *VARCHAR2(200):= 'EXEC
DBMS_STATS.GATHER_SCHEMA_STATS( ownname *=> ''LOAD'',
estimate_percent => 100, cascade => *TRUE,options => ''GATHER
AUTO'');';
BEGIN
* *EXECUTE IMMEDIATE *v_dbms_stats;
END;

ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at line 4
Why are you using EXECUTE IMMEDIATE to run a PL/SQL packaged procedure
from within PL/SQL when this works:

BEGIN
DBMS_STATS.GATHER_SCHEMA_STATS( ownname => 'LOAD',
estimate_percent => 100, cascade => TRUE,options => 'GATHER AUTO');
END;
/

Can you enlighten us as to why you think this exercise is absolutely
necessary?


David Fitzjarrell


Reply With Quote
  #13  
Old   
ddf
 
Posts: n/a

Default Re: using EXECUTE IMMEDIATE to run DBMS_STATS.GATHER_SCHEMA_STATS - 10-31-2008 , 11:52 AM



On Oct 31, 6:53*am, Kevin S <Sear... (AT) googlemail (DOT) com> wrote:
Quote:
When I run the block below, in oracle 10.2.0.3.0, I get the error
shown after. Is this a problem with my coding or is it just not
possible to run this commad in pl/sql?

Thanks

DECLARE
* * v_dbms_stats * *VARCHAR2(200):= 'EXEC
DBMS_STATS.GATHER_SCHEMA_STATS( ownname *=> ''LOAD'',
estimate_percent => 100, cascade => *TRUE,options => ''GATHER
AUTO'');';
BEGIN
* *EXECUTE IMMEDIATE *v_dbms_stats;
END;

ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at line 4
Why are you using EXECUTE IMMEDIATE to run a PL/SQL packaged procedure
from within PL/SQL when this works:

BEGIN
DBMS_STATS.GATHER_SCHEMA_STATS( ownname => 'LOAD',
estimate_percent => 100, cascade => TRUE,options => 'GATHER AUTO');
END;
/

Can you enlighten us as to why you think this exercise is absolutely
necessary?


David Fitzjarrell


Reply With Quote
  #14  
Old   
William Robertson
 
Posts: n/a

Default Re: using EXECUTE IMMEDIATE to run DBMS_STATS.GATHER_SCHEMA_STATS - 11-02-2008 , 09:37 AM



On Oct 31, 11:53*am, Kevin S <Sear... (AT) googlemail (DOT) com> wrote:
Quote:
When I run the block below, in oracle 10.2.0.3.0, I get the error
shown after. Is this a problem with my coding or is it just not
possible to run this commad in pl/sql?

Thanks

DECLARE
* * v_dbms_stats * *VARCHAR2(200):= 'EXEC
DBMS_STATS.GATHER_SCHEMA_STATS( ownname *=> ''LOAD'',
estimate_percent => 100, cascade => *TRUE,options => ''GATHER
AUTO'');';
BEGIN
* *EXECUTE IMMEDIATE *v_dbms_stats;
END;

ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at line 4
If you do want to call a PL/SQL procedure dynamically (although I
can't see why you would want to here) it would need to be 'CALL' and
not the SQL*Plus command 'EXEC', or else enclose it within a
'BEGIN...END;' block (including the PL/SQL semicolon not required by
the SQL 'CALL').


Reply With Quote
  #15  
Old   
William Robertson
 
Posts: n/a

Default Re: using EXECUTE IMMEDIATE to run DBMS_STATS.GATHER_SCHEMA_STATS - 11-02-2008 , 09:37 AM



On Oct 31, 11:53*am, Kevin S <Sear... (AT) googlemail (DOT) com> wrote:
Quote:
When I run the block below, in oracle 10.2.0.3.0, I get the error
shown after. Is this a problem with my coding or is it just not
possible to run this commad in pl/sql?

Thanks

DECLARE
* * v_dbms_stats * *VARCHAR2(200):= 'EXEC
DBMS_STATS.GATHER_SCHEMA_STATS( ownname *=> ''LOAD'',
estimate_percent => 100, cascade => *TRUE,options => ''GATHER
AUTO'');';
BEGIN
* *EXECUTE IMMEDIATE *v_dbms_stats;
END;

ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at line 4
If you do want to call a PL/SQL procedure dynamically (although I
can't see why you would want to here) it would need to be 'CALL' and
not the SQL*Plus command 'EXEC', or else enclose it within a
'BEGIN...END;' block (including the PL/SQL semicolon not required by
the SQL 'CALL').


Reply With Quote
  #16  
Old   
William Robertson
 
Posts: n/a

Default Re: using EXECUTE IMMEDIATE to run DBMS_STATS.GATHER_SCHEMA_STATS - 11-02-2008 , 09:37 AM



On Oct 31, 11:53*am, Kevin S <Sear... (AT) googlemail (DOT) com> wrote:
Quote:
When I run the block below, in oracle 10.2.0.3.0, I get the error
shown after. Is this a problem with my coding or is it just not
possible to run this commad in pl/sql?

Thanks

DECLARE
* * v_dbms_stats * *VARCHAR2(200):= 'EXEC
DBMS_STATS.GATHER_SCHEMA_STATS( ownname *=> ''LOAD'',
estimate_percent => 100, cascade => *TRUE,options => ''GATHER
AUTO'');';
BEGIN
* *EXECUTE IMMEDIATE *v_dbms_stats;
END;

ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at line 4
If you do want to call a PL/SQL procedure dynamically (although I
can't see why you would want to here) it would need to be 'CALL' and
not the SQL*Plus command 'EXEC', or else enclose it within a
'BEGIN...END;' block (including the PL/SQL semicolon not required by
the SQL 'CALL').


Reply With Quote
  #17  
Old   
William Robertson
 
Posts: n/a

Default Re: using EXECUTE IMMEDIATE to run DBMS_STATS.GATHER_SCHEMA_STATS - 11-02-2008 , 09:37 AM



On Oct 31, 11:53*am, Kevin S <Sear... (AT) googlemail (DOT) com> wrote:
Quote:
When I run the block below, in oracle 10.2.0.3.0, I get the error
shown after. Is this a problem with my coding or is it just not
possible to run this commad in pl/sql?

Thanks

DECLARE
* * v_dbms_stats * *VARCHAR2(200):= 'EXEC
DBMS_STATS.GATHER_SCHEMA_STATS( ownname *=> ''LOAD'',
estimate_percent => 100, cascade => *TRUE,options => ''GATHER
AUTO'');';
BEGIN
* *EXECUTE IMMEDIATE *v_dbms_stats;
END;

ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at line 4
If you do want to call a PL/SQL procedure dynamically (although I
can't see why you would want to here) it would need to be 'CALL' and
not the SQL*Plus command 'EXEC', or else enclose it within a
'BEGIN...END;' block (including the PL/SQL semicolon not required by
the SQL 'CALL').


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.