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 are the types of connection load-balancing?
What are the differences in clustering in sql server 2005 and 2008 or 2008 r2? : sql server DBA
Illustrate how to determine the amount of physical CPUs a Unix Box possesses (LINUX and/or Solaris).
I have A,B,C servers.i want to 3 servers jobs move to D server(target server)..how? note: i said that take the backup of msdb and restore to the target server..he said while restoring jobs replaced. what is the solution
What is dbcc? : sql server DBA
What the different topologies in which replication can be configured? : sql server DBA
Due to some maintenance being done, the sql server on a failover cluster needs to be brought down. How do you bring the sql server down? : sql server DBA
what is ora 24313?what is the procedure to exclude that error?
How to bind a cobol module to a given job? I am not able to understand this concept.Can anyone help me out as how to carry out this task?
what do you understand by flashback feature of oracle?
What the different components in replication and what is their use? : sql server DBA
can u plz tell me what r the mandatory skills for getting job as a sql dba......plz send me all details thank you my id :k.mohann.mohan@gmail.com
how can you initialize log miner?
What are the different types of database compression introduced in sql server 2008? : sql server DBA
what is a crs resource?