Hi Guys,
I am trying to run dbms_stats for a set of tables through a PL/SQL block and want to incorporate this in a shell script to automate it.
I am using execuute immediate, but I am getting the following error when I run this block:
DECLARE
v_stats varchar2(1000);
cursor st_cursor is
select owner, table_name from dba_tables where owner='XYZ' and table_name in(
'XX,
YY,
'ZZ',
'ZZ1',
'ZZ2');
BEGIN
for st_row in st_cursor loop
v_stats := 'execute dbms_stats.gather_table_stats(ownname=>'||''''||st _row.owner||''''||','||'tabname=>'||''''||st_row.t a
ble_name||''''||','||'estimate_percent=>1'||','||' method_opt=>'||''''||'FOR ALL INDEXED COLUMNS SIZE SKEWONLY'||''''||','||'
degree=> 6'||','||'granularity=>'||''''||'GLOBAL'||''''||', '||'cascade=>false);';
execute immediate v_stats;
end loop;
END;
/
ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at line 13
I will be running gather_index_stats in a separate cursor within this block, but want this to work. Any help would be appreciated
3 10985
I moved this question to it's own thread. You are more likely to receive assistance this way.
ADMIN
Saii 145
Expert 100+
when calling a proc/function in PL/SQL block, we dont need to use "execute proc", directly call it.
Hi Guys,
I am trying to run dbms_stats for a set of tables through a PL/SQL block and want to incorporate this in a shell script to automate it.
I am using execuute immediate, but I am getting the following error when I run this block:
DECLARE
v_stats varchar2(1000);
cursor st_cursor is
select owner, table_name from dba_tables where owner='XYZ' and table_name in(
'XX',
'YY',
'ZZ',
'ZZ1',
'ZZ2');
BEGIN
for st_row in st_cursor loop
v_stats := 'execute dbms_stats.gather_table_stats(ownname=>'||''''||st _row.owner||''''||','||'tabname=>'||''''||st_row.t a
ble_name||''''||','||'estimate_percent=>1'||','||' method_opt=>'||''''||'FOR ALL INDEXED COLUMNS SIZE SKEWONLY'||''''||','||'
degree=> 6'||','||'granularity=>'||''''||'GLOBAL'||''''||', '||'cascade=>false);';
execute immediate v_stats;
end loop;
END;
/
ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at line 13
I will be running gather_index_stats in a separate cursor within this block, but want this to work. Any help would be appreciated
Hi ,
Try this out: -
-
DECLARE
-
v_stats varchar2(1000);
-
-
BEGIN
-
-
for st_row in (select owner, table_name from all_tables where owner='XYZ and table_name in(
-
'XX,
-
YY,
-
'ZZ',
-
'ZZ1',
-
'ZZ2')
-
)
-
loop
-
-
v_stats := 'begin dbms_stats.gather_table_stats(ownname=>'||''''||st_row.owner||''''||','||'tabname=>'||''''||
-
st_row.table_name||''''||','||'estimate_percent=>1'||','||'method_opt=>'||''''||'FOR ALL INDEXED COLUMNS SIZE SKEWONLY'||''''||','||'
-
degree=> 6'||','||'granularity=>'||''''||'GLOBAL'||''''||','||'cascade=>false); end;';
-
execute immediate v_stats;
-
end loop;
-
-
end;
-
Hope this helps!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Joseph Ferris |
last post by:
Hello,
I am having an issue with page breaking that I hope someone will be
able to help me with. Still a relative "newbie", and I thought this
might be a good place to find some help. I have a...
|
by: Robert J. O'Hara |
last post by:
For some time I've made use of the max-width property in CSS to cause
my pages to appear as a centered block against a contrasting
background. This works well in new browsers (Mozilla, etc.) and...
|
by: Zambien |
last post by:
Hi all,
Here's my problem. I have tables that are using the menu/submenu idea
for hiding rows. This works fine in IE (of course) and does show/hide
correctly in netscape, but as soon as the...
|
by: Mark Schneider |
last post by:
I'm trying to avoid using <table> for formatting purposes where other,
reasonable means exist. I'm stuck trying to find a way to find an
equivalent for the code below.
<table align="center">...
|
by: Random Person |
last post by:
Does anyone know how to use VBA to relink tables between two MS Access
databases? We have two databases, one with VBA code and the other with
data tables. The tables are referenced by linked...
|
by: Alan Silver |
last post by:
Hello,
I understand the issue that tables should be used for tabular data and
not for layout, but I would like some clarification as to exactly what
constitutes tabular data.
For example, if...
|
by: axlq |
last post by:
Suppose I had to lay out a part of a page where I wanted to retain the
horizontal and vertical relationship of the elements. Yes, this is what
tables are for. I was curious if it can be done in...
|
by: Markus Ernst |
last post by:
Hello
This is a test example:
http://www.markusernst.ch/anthracite/
http://www.markusernst.ch/anthracite/living_divani.html
After googling and experimenting for several hours, I ended up...
|
by: Gary |
last post by:
Hello guys!
Bear with me, I am a newbie.
She is the Data Warehouse manager. She has about 50 users to use the
Oracle database from M$ Access via ODBC connection. All those users
have only...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |