The ArtOfBI.com Newsletter

Is stupid new and freshly informative on BI and EPM.

Save one little gremlin by not pouring water on its head.

Or, sign up for killer tips, tricks and other BI / EPM goodness delivered right to your inbox.

Hell just do both. Enter your email below.

Oh no what happened?
I already signed up.

BTW, Signing up gets rid of this annoying banner.

Cheers,
Christian & The ArtOfBi.com Team

Art of Business Intelligence > Databasetitle_li=Tricks n' Tips

Archive | Tricks n’ Tips

Extending Oracle Tablespace – Quick and Dirty

I was working on quick project and kept bumping an a “failure to initiate auto-extend…” message that was rather irritating.  I typically use SQLDeveloper over Toad and there is not immediate built-in functionality to manage tablespaces in that tool.  A quick Google search gave me some results and I figured I would quickly post the two step extension process here for later reference.

Step 1

Run the PL/SQL code to determine the current size of the tablespace in question. Notice how memory is divided by 1024 to get at the canonical data size.  The tablespace I was using for my project was the SYSTEM tablespace and it is referenced within the code in this post.  If you are using the USERS or a custom tablespace simple substitute your tablespace where you see SYSTEM.


select
file_name,
autoextensible,
(bytes/1024)/1024 usedmb,
(maxbytes/1024)/1024 maxmb,
round((((bytes/1024)/1024)
/ ((maxbytes/1024)/1024)) * 100) used_pct
from dba_data_files
where tablespace_name = 'SYSTEM';

Step 2

As we determined in the previous step, we now know how much of the tablespace is being used and what the current size and max sizes are.  To extend the space run the following query based on the information provided from the Step 1.  I want to increase my maxsize to a value that I know is within the bounds of my current volume but will still allow my data operations to continue without being held hostage by the error that started this discussion. To do that I pick a value such as 2000 MB and multiple it twice by 1024 (i.e.: 2000 x 1024 x 1024) .  The result of that math is the value I place for the maxsize in the following statement.


alter database datafile 'G:\ORACLEXE\ORADATA\XE\SYSTEM.DBF' autoextend on maxsize 2097152000;

Run the statement above and the tablespace maxsize will be set as desired.  Re-run the statement provided in Step 1 to see the values have changed and your percentage of use should now be changed as well.

References

http://garycoy.com/?page_id=13

Posted in Database, Tricks n' TipsComments (1)

SQL Pad Left Functionality (Oracle / SQL Server)

Every now an then one needs to pad a column value with a character or symbol in order to conform the resulting value to some standard. For example, a company may represent their stores by a maximum of 4 digits and each character in that 4-digit store number must contain a value as to not be confused with any other values..  In other words, store #99 would be represented as 0099 instead of just 99.

This is not uncommon practice. Often times, similar functionality is required when pulling data from the mainframe where “super keys” are paramount.  Our good friends at MS have set up SQL Server so that this is universally simple.  The code snippet in its basic form looks like this:

RIGHT('0000' +  [COLUMN NAME], 4)

This is straightforward.  Use the RIGHT function by concatenating the first parameter to a set number of padding characters and the column name in your table. Be sure to CAST that column as a string data type if pulling a numeric field.  Then, for the RIGHT functions second parameter, make its value the same number of character spaces required for your final value.

Oracle just had to be difficult.  In order to conduct the same operation using PL/SQL you must use a function, which I am still not sure how it completely works behind the scenes.  The syntax is as follows:

SELECT to_char([COLUMN NAME],'FM0000') AS result FROM table;

Update
Recently a reader posted the use of the Oracle function LPAD, which is much cleaner than the use of the FM function and works better than the SQL Server function. The syntax would be

SELECT LPAD('Test', 8, '0') AS result FROM dual;

This LPAD function has been relevant since 8i.

Conclusion

Each of the code snippets above will provide a conformed look at a column value.  SQL Server’s method seems to be a little more cut n’ dry than PL/SQL’s but they both get the job done.

Another great source for Oracle functions can be found at http://www.techonthenet.com/oracle/functions/lpad.php

Posted in Business Intelligence, Database, Tricks n' TipsComments (1)

Essbase ASO Version of BSO Dynamic Time Series

ASO does not provide an out-of-the-box version of dynamic-time-series (DTS) like its partner in crime, BSO. However, one straightforward approach to achieving this functionality is to implement a time aggregation dimension and leverage MDX functionality.  In this example we will house the Time Periods/Months (i.e.:  Mar, Apr, May, etc.) and the Years dimensions into two separate dimensions.  We then add an additional dimension called “Time Series” to the outline to support our ASO version of DTS.

Read the full story

Posted in Essbase, Tricks n' TipsComments (2)

My name is Christian Screen, a Business Intelligence mastermind working with mainly Oracle and Microsoft technologies. The views expressed here are my own and do not reflect the views of Oracle, Microsoft, or my employer. RSS