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
How does propagation differ between Advanced Replication and Snapshot Replication (read-only)?
What are the differences in clustering in sql server 2005 and 2008 or 2008 r2? : sql server DBA
how can you enable flashback feature?
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
What view(s) do you use to associate a user's SQLPLUS session with his o/s process?
What are the commands you'd issue to show the explain plan for "select * from dual"?
Illustrate how to determine the amount of physical CPUs a Unix Box possesses (LINUX and/or Solaris).
Can you tell me about your experience with the administration of COTS system..? Also, how do you set up seed data..?
You create a private database link and upon
connection, fails with: ORA-2085: connects to
how can you record information about current session?
Typically, where is the conventional directory structure chosen for Oracle binaries to reside?
how to restore files with rman?
who owns the operating system files created by the utl_file package?
Why would you call update statistics? : sql server DBA
What is the default fill factor value? : sql server DBA