My blog has moved!

You should be automatically redirected in 5 seconds. If not, visit
http://www.oraexplorer.com
and update your bookmarks.

Thursday, December 18, 2008

11g OCP upgrade exam

I just passed the 11g OCP upgrade after many excuses to postpone it.

I have to admit I was nervous a little bit because the last Oracle exam I've taken was more than one year ago. I was struggling a little bit at first. I tend to read too quickly (= careless). So at the beginning I missed couple phrases in question especially those saying please select two (or more) answers. I just answered one and then clicked Next. Note that system won't prompt you if you answer less than what it is looking for, but it will prompt if your answer more. :-(  After about 30 minutes, I realized something was not right. Fortunately I still had just enough time to go back and fix it. Whew!

Sunday, December 14, 2008

See initialization parameters from memory

One of Oracle 11g's new features is an ease of capturing the initialization parameter values currently in memory into a file.

select pfile from memory;
select spfile from memory;
select pfile='/tmp/cur_pfile.ora' from memory;

This comes in handy when you'd like to quickly verify changes especially after executing "alter system set" with scope=memory.

It also lets you see the current values of memory allocation in the Automatic Memory Management (AMM). Note that those values are at the top of the list prefixing with "__" (double underscores).

In addition to that it allows you peek into the current values of some hidden parameters too. This is a good alternative to having to run a query like below; Sample below is looking for a value of the "_b_tree_bitmap_plans" parameter. I got this code from Coskan's blog.

col name format a20
col value format a7
col deflt format a7
col description format a10
select a.ksppinm name,
b.ksppstvl value,
b.ksppstdf deflt,
decode
(a.ksppity, 1,
'boolean', 2,
'string', 3,
'number', 4,
'file', a.ksppity) type,
a.ksppdesc description
from
sys.x$ksppi a,
sys.x$ksppcv b
where
a.indx = b.indx
and a.ksppinm like '\_%' escape '\'
and a.ksppinm='_b_tree_bitmap_plans'
order by name
NAME                 VALUE   DEFLT   TYPE    DESCRIPTIO
-------------------- ------- ------- ------- ----------
_b_tree_bitmap_plans TRUE    TRUE    boolean enable the
                                              use of bi
                                             tmap plans
                                              for table
                                             s w. only
                                             B-tree ind
                                             exes

Note that the output of "select pfile from memory" does not show all initialization values - just those currently in memory. If you're interested in finding out, the orafaq web site has the complete list of all initialization parameters including hidden ones of all versions as early as version 7.3.4.

Friday, December 12, 2008

First Error with OLE 5

I just have time to install Oracle Enterprise Linux (OLE) on VMWare. The first error I encountered after trying to login into the 11g (11.1.0.6) database is this -

[oracle@oralnx1 ~]$ sqlplus / as sysdba

sqlplus: error while loading shared libraries:

/opt/oracle/product/11.1.0/db_1/lib/libnnz11.so:

cannot restore segment prot after reloc:

Permission denied.


Well, I guess this is not a new error. I googled for it and found the answer on Ravi's blog (Thanks!!!). As Metalink note 454196.1 says, it is a bug due to more aggressive way that SELinux policies are enforced in RHEL 5 and OEL 5. The fix is to make SELinux is running in "Permissive" mode instead of its default "enforcing" mode. The syntax is provided in Metalink document.

[root@oralnx1 ~]# setenforce 0

[oracle@oralnx1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Dec 12 08:14:32 2008

Copyright (c) 1982, 2008, Oracle. All rights reserved.

Connected to an idle instance.

Saturday, December 6, 2008

A new extended partition syntax in 11g

A new extended partition syntax can be used to designate a partition without knowing its name. The syntax must refer to a possible value for the partition. This syntax works for all cases when you have to reference a partition, whether it be range, list, interval, or hash. It supports all operations such as drop, merge, split, and so on.

Some samples are shown below -

create table SALES (
  id              number,
  order_date      date
)
partition by range (order_date)
(
  partition p1 values less than
  (to_date('01/01/2008','mm/dd/yyyy')),
  partition p2 values less than
  (to_date('02/01/2008','mm/dd/yyyy')),
  partition p3 values less than
  (to_date('03/01/2008','mm/dd/yyyy'))
);

Generally when you want to merge partitions, the syntax will have to refer to the partition names.

alter table SALES merge partitions
p2, p3
into partition p2_3; 

However, in 11g, the same can be accomplished by referring to a possible value for the partition with use of "for" syntax.

alter table SALES merge partitions
for(to_date('01/12/2008','mm/dd/yyyy')),
for(to_date('02/15/2008','mm/dd/yyyy'))
into partition p2_3;
SQL> select table_name, partition_name, high_value
from user_tab_partitions
where table_name = 'SALES';
TABLE_NAME PARTITION_ HIGH_VALUE
---------- ---------- ------------------------------
SALES      P1         TO_DATE(' 2008-01-01 00:00:00'
                      , 'SYYYY-MM-DD HH24:MI:SS', 'N
                      LS_CALENDAR=GREGORIA
SALES      P2_3       TO_DATE(' 2008-03-01 00:00:00'
                      , 'SYYYY-MM-DD HH24:MI:SS', 'N
                      LS_CALENDAR=GREGORIA

Or with dropping a partition -

SQL> alter table SALES drop partition
for(to_date('02/15/2008','mm/dd/yyyy'));
Table altered.
SQL> select table_name, partition_name, high_value
from user_tab_partitions
where table_name = 'SALES';   
TABLE_NAME PARTITION_ HIGH_VALUE
---------- ---------- ------------------------------
SALES      P1         TO_DATE(' 2008-01-01 00:00:00'
                      , 'SYYYY-MM-DD HH24:MI:SS', 'N
                      LS_CALENDAR=GREGORIA

Saturday, October 18, 2008

APEX - Requests to execute DML operations through "Automatic Row Processing (DML)" process

As a part of the button's properties, an execution of "Automatic Row Processing (DML)" process either INSERT, UPDATE or DELETE (assuming those operations are allowed) can be controlled by selecting an appropriate Database Action as shown below.

image

Many times, instead through a use of button, page submission is done by calling JavaScript "onSubmit" function. How will we select a DML's database actions through this approach?

APEX provides a way. The DML process will execute a requested database's action based on the request value containing one of the listed values here -

image

By default, the request value of a button is the button name itself. But for onSubmit function, the request value is what in the passing value. For example, onSubmit('SAVE') or onSubmit('APPLY CHANGES') will execute database's UPDATE operation.

The one I found the most useful is APPLY%CHANGES%. The wildcard allows the request value to be flexible.

I could use doSubmit('APPLY_CHANGES_D1') and doSubmit('APPLY_CHANGES_U1') to cause the update operation of all items of the current page. At the same time, it allows me to perform other different operations based on request values from using conditional processing.

The application I'm working on has two created-on-the-fly buttons in the "Display Only" item. The VIEW FILE link and Delete button are visible when file is stored in table. If not, only Upload button is visible.

  1: declare
  2:   v_link  varchar2(300);
  3: begin
  4: if :P8_UPLOAD_DOC_ID <> '0' then
  5:   select '<td><a href="#OWNER#.pr_download_file?p_file=' || :P8_UPLOAD_DOC_ID || '">VIEW FILE</a></td> <td><a href="javascript:confirmDelete(htmldb_delete_message,''APPLY_CHANGES_D1'');"> <img border="0" src="#WORKSPACE_IMAGES#delete.jpg" id="img_delete1"</a></td>'
  6:   into v_link
  7:   from PRODUCT
  8:   where ID = :P8_PRODUCT_ID;
  9: else
 10:   v_link := '<td></td> <td><a href="javascript:doSubmit(''APPLY_CHANGES_U1'')"><img border="0" src="#WORKSPACE_IMAGES#upload.jpg" id="img_upload1"></a></td>'; 
 11: end if;
 12:   return v_link;
 13: end;
 14: 

When either button is clicked, all item information on the form will be saved (through DML's update process). If Upload button is pressed, then page will be re-directed to the upload page. If Delete button is pressed, after confirmation, it will remove the actual file which is stored in a different table.

Monday, September 15, 2008

Programming for kids

I've been looking for a way to help my kid learning computer programming. My daughter and I tried out the trial version of "Phrogram" which is listed in the top hits when googling for "kid programming". It is nice, well-made and powerful by just looking at provided samples. Its look & feel and language look a lot like Visual Basic. But I think it is still considered as intermediate to advanced levels because you have to know syntaxes and actually typing them in. It would be definitely something I'd like her to learn if she grows up a little bit.

This week, I ran into this new open-source programming for kids called "Scratch" by MIT Media Lab. image Not only word "open source" interests me, the drag-n-drop feature makes it a lot easier to learn programming. Even though this is not really focusing on computer language learning, it, instead, emphasizes on developing design process skill which I think it is better in a long-term because it can universally apply not only to all programming languages but also other areas related to mathematic and science.

The other nice thing is the ability to upload and share your project on the web site.

Friday, August 15, 2008

Oracle APEX displays report's column heading 90 degree rotation

One of the cool things about Oracle APEX is ability to embed HTML tags into everything you could display. This includes simple HTML tags like

Add a break Employee<br>Name

Add color <font color="#FF0000">Employee Name</font>

image

Or more complex one like

Rotate 90 degree vertically (work with IE only)

<div style="writing-mode: tb-rl">Employee Name</div>

Friday, July 4, 2008

WOT - Web of Trust

Yesterday I just downloaded Firefox 3, which just set the Guinness World Records for the most software downloads in a day, and started looking around for its add-ons. This one is interesting and useful.

WOT (Web of Trust) is the free Internet security add-on for web browsers. The reputation ratings are categorized into four – trustworthiness, vendor reliability, privacy, and child safely. These ratings are ranked by the WOT web community. The goal is to helps make the Internet safer by sharing experiences.

The nice thing is the visual icons in different colors (green is good, red is bad) showing the web site’s ratings on search web sites like Google. This definitely helps me to proceed to the low-ranking web site cautiously.

clip_image002[5]

Have a safe surf.

Tuesday, June 24, 2008

A Million Thanks to Mom

My kid found this e-card on the Hallmark web site for the Mother's day. We really like the voices of hoops and yoyo - two cartoon characters. Since the card says, "A Million Thanks to Mom", we initially thought it'd probably be done by one million. But apparently it is not. So for fun, we let it run, and it keeps going and going. We've decided to let it continue to see how far it can go. Please note that it takes about one whole day to reach 1M on my desktop machine.




If you want to try out, here is the link, select "A Million Thanks for Mom".

Let me know how far you make it.

[Updated 6/3] Reached 3 millions and still going...
 


[Updated 6/4] Wow 4 millions now. Umm.. I don't know whether or not I should stop it, or let it continue.

 

[Updated 6/10] Now I'm reaching the 10 million “Thanks”. I can’t believe this thing can go on and on. I'm tempted to let it continue and see how far it can go.

[Updated 6/20] After about twenty days of this journey, I just reached 20 million Thanks. Wow..

My daughter urged me to continue. Well, let’s do it.

ThankYou20M_0620

[Update 6/23] Somehow, my XP desktop was rebooted unexpectedly over weekend :-( Well, I guess my 20-day “FUN” trip has to come to the end. It is sad but I feel relief because finally I can use my computer without annoying noises.

Sunday, June 15, 2008

Oracle SQL Developer Migration Workbench

The Oracle SQL developer is not only a great tool for SQL development, with its migration workbench, it is an excellent tool for database migration. Did I also mention it is free?

To get it started, you will need to download the latest version of the tool which is version 1.5.1. Also it is recommended to install the latest updates. The current release of update as of 6/15 is 1.5.1.54.40.

Next, you will need to create a repository. An database account, which has CREATE SESSION, RESOURCE, and CREATE VIEW must be created first. Then logon into SQL Developer as that account. From the tool, create a repository from Migration menu > Repository Management > Create Repository. This process creates a bunch of MD* and MIGR* tables and packages.

To connect to other non-Oracle databases, you will need to create connections through provided JDBC drivers. If somehow, your SQL Developer does not show these 3-rd party connection tabs, you will have to configure it. Instruction is clearly documented on Oracle site here.

image

In my case, I migrate one of our legacy applications on MS SQL to Oracle. Unfortunately this application contains column name named “rowid”, which is Oracle’s reserved word, in most of tables. The tool has a mechanism to append a suffix “_” (with no quotes) if it encounters these reserved words. So “rowid” will be converted to “rowid_”. To see the list of all reserved words, you can just query “KEYWORD” column in MIGRATION_RESERVEDW_WORDS table under the repository schema. Unfortunately, the “rowid” is not really in this table, I have to insert this manually. I added a keyword “privilege” as well because, again, there is a column named “privilege” used in application.

insert into migration_reserved_words values ('rowid');
insert into migration_reserved_words values ('privilege');
I encountered a bug (which Turloch O'Tierney pointed out - thanks) when using version 1.5.1 without the latest patch. In the function “first_char_check” under MIGRATION_TRANSFER package, a number “4” is missing. The impact of this is that If the column name is numeric prefix, for example, 3Q2008, a letter “A” will be prefixed into it to be “A3Q2008”. But due to this bug, it won’t do it with, for example, 4Q2008, resulting in a failure when trying to create table. With the latest patch, it seems like it was fixed already because I now see number 4.

v_allowed := C_DISALLOWED_CHARS || '012356789_$';

The process of migration is straight-forward. You will start with capture then convert. You can capture and convert the whole database at once. But I would not recommend that because if error is encountered, it might be difficult to troubleshoot.

You can just capture only the table first, this will create a converted script. Before running it, please inspect it first and comment un-needed sections especially CREATE default USER syntax and CONNECT using default user. By running the converted script, it will create the definitions of tables, sequences, triggers and constraints. If there is no error, then you can run to move data.

Once data is there, repeat the steps with stored procedures and views. Obviously, you will just need to run the converted script – there is no need for data movement.