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 / 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 |
Explain the difference between a data block, an extent and a segment.
What is the difference between the SQL Loader and IMPORT utilities?
what is the last version,the release date of that version and fix pack of ibm db2 udb?
When a user process fails, what background process cleans up after it?
Give the two types of tables involved in producing a star schema and the type of data theyhold.
What are the different sql server versions you have worked on? : sql server DBA
What SQL query from v$session can you run to show how many sessions are logged in as a particular user account?
Give two examples of how you might determine the structure of the table DEPT.
Which autogrowth database setting is good? : sql server DBA
what do you understand by fine-grained auditing?
WHEN DOWN TIME WHAT CAN U DO?
How can you gather statistics on a table?