Joel Kallman lists steps to make apex.oracle.com run faster, like turning on the KeepAlive setting in Oracle HTTP Server, reducing the open window for Web crawlers in robots.txt, replacing a Database Access Descriptor with an httpd.conf rewrite rule and increasing file system caching and memory size. Read the details at Making apex.oracle.com fast (again).
Filed in Oracle, Tips with 0 Comments | Tags: apexIn this video interview with ZDNet.com.au, Kyte explains how many questions he receives equate to “my car won’t start”. “I’m going to do it to you — my car won’t start, why? Give me the solution. I’m not going to tell you what errors I see on the dashboard; I’m not going to tell you if I filled the car up with gas recently; I’m not going to tell you if it’s making a noise or not making a noise; but my car won’t start, why not? There’s insufficient data to even begin to answer a question like that.” Kyte also explains how the internet has changed how questions are asked, and how he doesn’t reply with RTFM.
via How developers should ask for help: Blogs – Null Pointer – ZDNet Australia (via)
Filed in Oracle, Tips with Comments Off | Tags: asktom, tom kyte, videoThe following are 10 blogging tips I extracted from Tim Ferriss’s presentation (video below) originally titled “Scalable Blogging Behaviors: How to Grow from 1 to 1,000,000 Readers”, then re-titled to “How to Blog without Killing Yourself“:
Of course the above tips worked for Tim but they may or may not work for you and me.
Here is Tim’s full 50 minute presentation:
Filed in Tips with Comments Off | Tags: bloggingEvery PL/SQL developer knows, or at least should know, that WHEN OTHERS THEN NULL is a hidden bug; Ask Tom.
But, what about WHEN OTHERS THEN RAISE?
I have known PL/SQL developers who follow a “standard” of adding:
EXCEPTION
WHEN OTHERS
THEN
RAISE;
END;
to every PL/SQL block. The reasoning behind this practice, as explained to me:
When asked if he was joking when he added “when others then raise;” Shoblock replied:
not joking at all. very serious. I know it’s not needed, but it helps to point out to people who might modify your code later on that you do indeed want all other exceptions to be raised. it basically prevents someone from adding “when others then null” while you’re on vacation.
Now, before rushing back and starting to sprinkle WHEN OTHERS THEN RAISE all over your code, please read Tom Kyte’s take on this seemingly harmless line of code:
why do people do this?????
EXCEPTION WHEN OTHERS THEN RAISE; END;
what is the point, other than to make the code infinitely harder to debug. You know what you did by coding that?
YOU HIDE THE LINE NUMBERS FROM US. No longer can you tell where the error came from !!!!!
Tom is right. Consider:
SQL> DECLARE
2 l_var varchar2 (30);
3 BEGIN
4 SELECT object_name
5 INTO l_var
6 FROM all_objects
7 WHERE ROWNUM <= 2;
8 END;
9 /
DECLARE
*
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 4
Now let’s add WHEN OTHERS THEN RAISE:
SQL> DECLARE
2 l_var varchar2 (30);
3 BEGIN
4 SELECT object_name
5 INTO l_var
6 FROM all_objects
7 WHERE ROWNUM <= 2;
8 EXCEPTION
9 WHEN OTHERS
10 THEN
11 RAISE;
12 END;
13 /
DECLARE
*
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 11
As you can see, WHEN OTHERS THEN RAISE masked the line number where the actual error occurred. In the above example, the real error occurred at line 4 not 11.
WHEN OTHERS THEN NULL is a hidden bug but WHEN OTHERS THEN RAISE hides the bug.
Filed in Oracle, Tips with 4 Comments | Tags: exceptionThe following software utilities and tools will help you work faster and make you more efficient at using your computer.
EnsoEnso is a free application launcher, but it is also more than just that. Enso is similar to Ubiquity, however, Enso works at the Windows operating system level, not just inside your browser. It is available to you in any application you’re using. On the other hand, Ubiquity is open-source, Enso is not. Enso is also similar to Quicksilver on Mac.
Walt Mossberg of the Wall Street Journal explains:
Enso is dead simple to use. You just hold down the Caps Lock key and type an Enso command, which is displayed in a translucent overlay. Once the command is typed, you simply release the Caps Lock key to activate it, and the overlay disappears. If you type fast, it all happens in a flash. For instance, to launch the Firefox Web browser, you just hold down the Caps Lock key and type "open firefox." To look up the meaning of the word "proclivity," you just hold down the Caps Lock key and type "define proclivity."
Other launchers: Launchy and Colibri. Google Desktop can also be used as an application launcher.
CLCLCLCL is a freeware clipboard caching utility. It allows you to stack things (text, images…) on your clipboard in one batch then bounce once to the destination and paste them all in the appropriate places, one at a time.

Other clipboard enhancers: Jumpcut and iClip for Mac.
AutoHotkeyAutoHotkey is a free, open-source macro tool that allows you to automate almost anything by sending keystrokes and mouse clicks. You can write a mouse or keyboard macro by hand or use the macro recorder. Using AutoHotkey, virtually any key, button, or combination can become a hotkey.
Other macro utilities: TextExpander and Typinator for Mac.
Virtual DesktopsMicrosoft PowerToys for Windows XP have many useful (and free) “toys”, but one of the most useful is the “Virtual Desktop Manager”. It allows you to manage up to four virtual desktops, each with a taskbar controller, unique wallpapers, and hotkey support. Virtual desktops provide an excellent way to kill distractions, stay focused and concentrate on the task at hand.
On Linux, both GNOME and KDE have virtual desktops built-in. The Leopard version of Mac OS X added this feature, called Spaces.
Almost all operating systems and applications that run on them have keyboard shortcuts. There is a reason why they are called shortcuts, it’s because once you master them it takes shorter time to perform a task using keyboard shortcuts than using the mouse. The following is a list of common and useful shortcuts:
I have been using the above tools for a while. I can now do things on my computer faster than I’ve ever been able to.
Other than the ones mentioned above, what tools or tips do you use that help you be more productive using your computer?
Filed in Technology, Tips with 4 Comments | Tags: tool, windowsA cursor FOR loop is a PL/SQL loop statement. It is a loop that is associated with a cursor embedded within the loop boundary.
There are two types of cursor FOR loops: SQL Cursor FOR loop and Explicit Cursor FOR Loop.
In SQL Cursor FOR loops, you include the text of a query directly in the FOR loop. For example:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set serverout on
SQL> BEGIN
2 FOR item IN
3 ( SELECT last_name, job_id
4 FROM employees
5 WHERE job_id LIKE '%CLERK%'
6 AND manager_id > 120 )
7 LOOP
8 DBMS_OUTPUT.PUT_LINE
9 ('Name = ' || item.last_name || ', Job = ' || item.job_id);
10 END LOOP;
11 END;
12 /
Name = OConnell, Job = SH_CLERK
Name = Grant, Job = SH_CLERK
Name = Bissot, Job = ST_CLERK
...
PL/SQL procedure successfully completed.
In Explicit Cursor FOR Loops, you declare a cursor that specifies a query, and then reference the cursor in the FOR loop. For example:
SQL> DECLARE
2 CURSOR c1 IS SELECT last_name, job_id FROM employees
3 WHERE job_id LIKE '%CLERK%' AND manager_id > 120;
4 BEGIN
5 FOR item IN c1
6 LOOP
7 DBMS_OUTPUT.PUT_LINE
8 ('Name = ' || item.last_name || ', Job = ' || item.job_id);
9 END LOOP;
10 END;
11 /
Name = OConnell, Job = SH_CLERK
Name = Grant, Job = SH_CLERK
Name = Bissot, Job = ST_CLERK
...
PL/SQL procedure successfully completed.
In both examples, you do not need to declare the record variable item, PL/SQL implicitly creates it for you with fields corresponding to the columns of the result set.
Steven Feuerstein gives us the following recommendations about cursor FOR loops which he learned from one of his mentors in the PL/SQL world, Bryn Llewellyn, Oracle’s PL/SQL product manager:
Never use a cursor FOR loop when you’re writing new code for normal production deployment in a multiuser application.
If you expect to retrieve just one row, use an implicit SELECT INTO query.
If you expect to retrieve multiple rows of data and you know the upper limit (as in, “I will never get more than 100 rows in this query”), use BULK COLLECT into a collection of type varray whose upper limit matches what you know about the query.
If you expect to retrieve multiple rows of data and you do not know the upper limit, use BULK COLLECT with a FETCH statement that relies on a LIMIT clause to ensure that you do not consume too much per-session memory.
If your existing code contains a cursor FOR loop, you should perform a cost-benefit analysis on converting that code, based on these recommendations.
Visit this page to read Steven’s full explanation and examples of each of the above recommendations.
In short, stop using cursor FOR loops and start using BULK COLLECT. It’s that simple.
Filed in Oracle, Tips with 20 Comments | Tags: bulk collect, cursor, loop
VirtualBox, Virtual PC, VMware Workstation and a few other software packages help you create and run multiple virtual machines on your desktop or laptop enabling you to run multiple operating systems simultaneously on a single computer.
My personal favorite is VirtualBox (recently acquired by Sun Microsystems), not only because it is freely available as Open Source Software and runs on Windows, Linux and Macintosh but also because it has great features and supports a large number of guest operating systems.
Last Saturday I used VirtualBox to create a new virtual machine (VM) running Windows XP Pro and Oracle Database 11gR1. First, I created a “base” VM with only Windows XP pro SP3 installed. I then detached the virtual disk file (VDI) from the VM. I ended up with a VDI file that I can clone as many times as I want eliminating the need to install a new operating system every time I create a new VM.
Cloning a virtual disk in VirtualBox is done using the command line. For example, to clone WindowsXP.vdi as a new virtual disk called WindowsXPProOraDB11gR1.vdi, you would issue this command:
VBoxManage clonevdi WindowsXP.vdi WindowsXPProOraDB11gR1.vdi
You would then assign WindowsXPProOraDB11gR1.vdi as the virtual hard drive of a new virtual machine.
The installation of Oracle Database 11gR1 on a new Windows XP VirtualBox VM on my laptop went very smoothly, but I had to troubleshoot a couple of things on the VM: A missing loopback adapter and a 100% CPU usage.
My laptop and the newly created VM do not have a static IP address. Dynamic Host Configuration Protocol (DHCP) is used to assign dynamic IP addresses on the network. According to the documentation, before installing Oracle Database onto a computer that uses the DHCP protocol, you need to install a loopback adapter to assign a local static IP address to that computer. I followed the instructions found in the Oracle Database Pre-installation Requirements document to install the loopback adapter. After that, the database installed without any issues.
Now that my WinXP VM and 11g Database are up and running, I noticed that the oracle.exe process was consuming 100% of the CPU. I waited a few minutes, but the CPU usage did not go down, it stayed at 100%. After a quick search, I found these two forum posts: post 1 and post 2. Since this is a test database, I did not hesitate to follow the instructions in post 2 and was able to bring the CPU usage down to a normal level.
Virtual machines are a great way to learn and try new software and applications without the need to buy new hardware or messing up your existing computer. You may even have fun embarking on some virtual adventures.

The document below contains patterns of bad SQL and PL/SQL code that Gojko Adzic has repeatedly found in various applications and databases. Some of the bad practices include:
Use of magic numbers and strings instead of NULL.