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

Explain the difference between a data block, an extent and a segment.

2 Answers  


What is the difference between the SQL Loader and IMPORT utilities?

3 Answers  


what is the last version,the release date of that version and fix pack of ibm db2 udb?

0 Answers  


When a user process fails, what background process cleans up after it?

1 Answers  


Give the two types of tables involved in producing a star schema and the type of data theyhold.

2 Answers  






What are the different sql server versions you have worked on? : sql server DBA

0 Answers  


What SQL query from v$session can you run to show how many sessions are logged in as a particular user account?

3 Answers  


Give two examples of how you might determine the structure of the table DEPT.

2 Answers  


Which autogrowth database setting is good? : sql server DBA

0 Answers  


what do you understand by fine-grained auditing?

0 Answers   Oracle,


WHEN DOWN TIME WHAT CAN U DO?

1 Answers   TCS,


How can you gather statistics on a table?

3 Answers  


Categories