Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

how can you implement fine-grained auditing?

1087


What happens on checkpoint? : sql server DBA

1049


how can you create a user-defined lock?

980


what are the differences of where and if in SAS?

2150


how to restore files with rman?

2260


What are the operating modes in which database mirroring runs? : sql server DBA

1128


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.

2219


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

1901


What authentication modes does sql server support? : sql server DBA

1156


What is the importance of a recovery model? : sql server DBA

982


How can you control the amount of free space in your index pages? : sql server DBA

1267


what do you understand by flashback feature of oracle?

961


Which autogrowth database setting is good? : sql server DBA

1091


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

975


What are the different types of database compression introduced in sql server 2008? : sql server DBA

1057