Home » SQL & PL/SQL » SQL & PL/SQL » Cursor throwing error while passing to dbms_stats.gather_schema_stats
Cursor throwing error while passing to dbms_stats.gather_schema_stats [message #677918] Tue, 22 October 2019 14:23 Go to next message
chavva.kiru@gmail.com
Messages: 23
Registered: April 2012
Location: hyderabad
Junior Member
Hi,

Below Cursor is throwing error while passing through schema_stats procedure.

error as:Encountered the symbol "DBMS_STATS" when expecting one of the following:=.(@ % The symbol ":=

can any one please help how to rectify below issue

declare
cursor c1 is
select distinct owner from all_tables;
begin
for i in c1
loop
exec dbms_stats.gather_schema_stats(ownname=>i.owner);
end loop;
end;
/
Re: Cursor throwing error while passing to dbms_stats.gather_schema_stats [message #677919 is a reply to message #677918] Tue, 22 October 2019 14:34 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

From your previous topics:

Michel Cadot wrote on Tue, 01 October 2019 20:09

From your previous topic:

Michel Cadot wrote on Wed, 25 September 2019 08:04

From your previous topics:

Michel Cadot wrote on Wed, 25 September 2019 08:03
Michel Cadot wrote on Thu, 06 October 2016 07:30

From your previous topic:

Michel Cadot wrote on Mon, 19 January 2015 07:22

From your previous topic:

Michel Cadot wrote on Thu, 16 August 2012 16:20
From your previous topics:

BlackSwan wrote on Wed, 11 April 2012 16:43
Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/
BlackSwan wrote on Wed, 11 April 2012 20:29
...
READ & FOLLOW the Posting Guidelines! http://www.orafaq.com/forum/t/88153/0/
With any SQL question, Post a working Test case: create table and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Before, Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.

Regards
Michel
In addition, Barbara helped you so much in your previous topics providing you codes and examples and you did never feedback and thank her.
Are you the kind of parasite we saw too much in these days?
Or are you a valuable person who deserves to be helped?
Re: Cursor throwing error while passing to dbms_stats.gather_schema_stats [message #677921 is a reply to message #677919] Wed, 23 October 2019 03:04 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
exec is a sqlplus command. PL/SQL doesn't understand it.
Re: Cursor throwing error while passing to dbms_stats.gather_schema_stats [message #677937 is a reply to message #677921] Thu, 24 October 2019 11:13 Go to previous message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
I would just run the program dbms_stats.GATHER_DATABASE_STATS but if you want to do a schema at a time then do the following. You have to have DBA priviledges to do this

BEGIN
    FOR Pnt IN (  SELECT Owner
                    FROM Dba_objects
                GROUP BY Owner)
    LOOP
        DBMS_STATS.Gather_schema_stats (Ownname => Pnt.Owner);
    END LOOP;
END;
/
Previous Topic: Two digit decimal
Next Topic: Multiple Out Parameters Function in Select Statement - Oracle
Goto Forum:
  


Current Time: Thu Mar 28 04:56:07 CDT 2024