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?



I want to reuse a piece of code inside a stored procedure. This piece of code need to be invoked m..

Answer / 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

More DB Administration Interview Questions

Illustrate how to determine the amount of physical CPUs a Unix Box possesses (LINUX and/or Solaris).

0 Answers  


Name two files used for network connection to a database.

5 Answers  


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?

1 Answers  


Explain the difference between a FUNCTION, PROCEDURE and PACKAGE.

0 Answers  


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

0 Answers  






how do we explain a project in cognos in an interview? please help me. Also how do we perform testing in cognos after creating reports?

0 Answers   HSBC,


wat is global index and local indes

1 Answers   Oracle,


what is the use of home directory???

1 Answers   HP,


How many memory layers are in the shared pool?

3 Answers  


if monday take full backup and tuesday it was cumulative backup and wednesday we taken incremental backup, thursday some disaster happen then what type of recovery and how it will take?

1 Answers  


what is meant by gateway

1 Answers   IBM,


What are the steps you will take, if you are tasked with securing an SQL Server?

1 Answers   STC,


Categories