I want to reuse a piece of code inside a stored procedure.
This piece of code need to be invoked multiple times inside
the procedure based on some different conditions. How to
achieve this?
Answer Posted / mohapatra.gouranga@gmail.com
Best answer is:
SELECT df.tablespace_name "Tablespace",
df.bytes / (1024 * 1024) "Size (MB)",
SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "%
Free",
Round((df.bytes - SUM(fs.bytes)) * 100 /
df.bytes) "% Used"
FROM dba_free_space fs,
(SELECT tablespace_name,SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT df.tablespace_name tspace,
fs.bytes / (1024 * 1024),
SUM(df.bytes_free) / (1024 * 1024),
Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 /
fs.bytes), 1),
Round((SUM(fs.bytes) - df.bytes_free) * 100 /
fs.bytes)
FROM dba_temp_files fs,
(SELECT tablespace_name,bytes_free,bytes_used
FROM v$temp_space_header
GROUP BY tablespace_name,bytes_free,bytes_used) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY
df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
ORDER BY 4 DESC;
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
what is the role of dip user in our database?
What types of replication are supported in sql server? : sql server DBA
how can you connect from 10g user to 11g user??
What purpose does the model database server? : sql server DBA
Why does Oracle not permit the use of PCTUSED with indexes?
who owns the operating system files created by the utl_file package?
what is the last version,the release date of that version and fix pack of ibm db2 udb?
what are the types of connection load-balancing?
You have found corruption in a tablespace that contains static tables that are part of a database that is in NOARCHIVE log mode. How would you restore the tablespace without losing new data in the other tablespaces?
What is the difference between the 2 operating modes of database mirroring? : sql server DBA
Does any body has ORACLE Certification Dumps or Materials on 9i DBA, 10G DBA, Internet Application Developer, OCP 8i to 10g DBA Upgrade, Oracle 11i if any body have it, please kindly drop an email to: taruni_2k8@yahoo.com
Explain about your sql server dba experience? : sql server DBA
How to start SQL Server in minimal configuration mode?
how can you find out if a table can be redefined?
What spfile/init.ora file parameter exists to force the CBO to make the execution path of a given statement use an index, even if the index scan may appear to be calculated as more costly?