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 can you implement fine-grained auditing?
What happens on checkpoint? : sql server DBA
how can you create a user-defined lock?
what are the differences of where and if in SAS?
how to restore files with rman?
What are the operating modes in which database mirroring runs? : sql server DBA
Database crashes. Corruption is found scattered among the file system neither of your doing nor of Oracle's. What database recovery options are available? Database is in archive log mode.
I have kept recovery catalog on same target database and taken backup of target DB to disk. deleted the target DB & tried to restore and revoer DB using the backup on disk but it is not possible, how do we restore & recover DB
What authentication modes does sql server support? : sql server DBA
What is the importance of a recovery model? : sql server DBA
How can you control the amount of free space in your index pages? : sql server DBA
what do you understand by flashback feature of oracle?
Which autogrowth database setting is good? : sql server DBA
What are the different sql server versions you have worked on? : sql server DBA
What are the different types of database compression introduced in sql server 2008? : sql server DBA