msgbartop
News, views, tips and tricks on Oracle and other fun stuff
msgbarbottom

World Population = World Population + 1

Today, my wife Jasmine, my son George and I welcomed Julie, the latest addition to the Awad family. Jasmine gave birth to Julie, a beautiful 8.2 lbs baby girl, at 10:41 AM (PST) on September 26, 2006. Both mom and baby are doing fine. As a result of this life changing event, I have taken a three week “vacation”, mainly staying home changing diapers and staying up most nights (since we have no family members around to help us).

So, I will be blogging infrequently during the coming three weeks… I hope to get back to normal routine before my trip to San Francisco for Oracle OpenWorld.

Filed in Personal with 15 Comments | Tags:


When Your Bind Variable is Invalid and Your Column is Weird

Did you know that you cannot use a bind variable if it has a specific name? And did you know that column names in your tables can be as cryptic as !@#$%^?

Invalid bind variable name

SQL reserved words cannot be used as bind variables. For example:

  SQL> var to number;
  SQL> var from number;
  SQL> var where number;
  SQL> var myto number;
  SQL> exec :to := 1; :from := 1; :where := 1; :myto := 1;

  PL/SQL procedure successfully completed.

  SQL> SELECT * FROM dual WHERE 1 = :to;
  SELECT * FROM dual WHERE 1 = :to
                                *
  ERROR at line 1:
  ORA-01745: invalid host/bind variable name


  SQL> SELECT * FROM dual WHERE 1 = :from;
  SELECT * FROM dual WHERE 1 = :from
                                *
  ERROR at line 1:
  ORA-01745: invalid host/bind variable name


  SQL> SELECT * FROM dual WHERE 1 = :where;
  SELECT * FROM dual WHERE 1 = :where
                                *
  ERROR at line 1:
  ORA-01745: invalid host/bind variable name


  SQL> SELECT * FROM dual WHERE 1 = :myto;

  D
  -
  X

Update Oct 14 2006: Refer to Ed’s post on how you can use the reserved words as bind variables as long as you quote them.

Weird, but valid column names

Someone at OraQA.com asked how to avoid special characters in column names. So, I did a little experiment and discovered that you could create tables with column names containing special characters like punctuation marks, dollar signs, percent signs… pretty much most of the keys on your keyboard. For example:

SQL> set define off
SQL> CREATE TABLE t
  2    ("this%is,so-,cool$,man()" VARCHAR2(10),
  3    "This@#is^~even+&cooler" NUMBER)
  4  /

Table created.

SQL> desc t;
 Name                                      Null?    Type
 ----------------------------------------- -------- ---------------

 this%is,so-,cool$,man()                            VARCHAR2(10)
 This@#is^~even+&cooler                             NUMBER

SQL> INSERT INTO t
  2       VALUES ('A', 1)
  3  /

1 row created.

SQL> INSERT INTO t
  2       VALUES ('B', 2)
  3  /

1 row created.

SQL> SELECT *
  2    FROM t
  3  /

this%is,so This@#is^~even+&cooler
---------- ----------------------
A                               1
B                               2

Now, who would use such column names and why?!

Update Oct 14 2006: Refer to Sergio’s and Marco’s posts for more quotation magic.

Filed in Oracle, Tips with 2 Comments | Tags:


OK, I Will be There Too

I’m late, but as the saying goes, better late than never. I just signed up for Oracle OpenWorld 2006 and purchased the airline ticket last Friday. I will be attending only the Oracle Develop part of it though. I will be flying from PDX to SFO on October 22nd and flying back on the 25th.

I booked the hotel through the Oracle OpenWorld registration. However, Sue was right when she said back in August: “if you’ve not booked your hotel for Oracle OpenWorld in San Francisco yet, you’re probably not going to get your first choice”. Indeed, I did not get my first choice. I preferred a hotel closer to the event location (Hilton San Francisco and Moscone Center). Instead, I will be staying in the Hilton Garden Inn, which is fine except that it is 12 miles (~ 19 km) away from downtown San Francisco. Fortunately, Oracle provides complimentary shuttle service between the hotel and Moscone Center.

In addition to the “expert-led, in-depth technical sessions, hands-on labs, advanced how-tos, and detailed tutorials” offered by the Oracle Develop program, I am looking forward to attending the second annual OpenWorld blogger meetup, organized by Mark Rittman. I did not attend last year’s gathering, so, I am looking forward to meeting the people behind the many excellent Oracle blogs.

Here are some of the sessions I’m planning to attend:

  • Web Services Development, Deployment, Security, and Testing Made Easy with Oracle JDeveloper
  • Administration and Deployment of Oracle BPEL Process Manager (for Beginners)
  • 10 Reasons to Choose Oracle JDeveloper and Oracle Application Development Framework Faces: A Real Project Perspective
  • 10 Things You Should NEVER Do in PL/SQL
  • Secure SQL Coding: How to Avoid SQL Injection Attacks
  • PL/SQL Performance: Debunking the Myths
  • Advanced BPEL
  • Oracle JDeveloper Treasure Hunt: The Hidden Oracle JDeveloper Gems

Hope to see you there!

Filed in Oracle with Comments Off | Tags:


Browse 188+ Feeds The Grazr Way

I used Grazr to build the following nifty little widget to display a “live” list of all the blogs and news sources that are aggregated by OraNA.

In addition to its really cool AJAX look and feel, this Grazr OPML viewer/reader has some nice features like:

  • Different viewing options: three pane view, a slider view and a single pane view.
  • Option to open the viewer in a new window.
  • Keyboard controls to let you move around from one level to another.
  • A sharing feature that lets you easily customize your own display and modify the code snippet for placement in many blogging platforms.

But the feature that is also very interesting is the ability to automatically include and view comment feeds for each post (if supported by the blogging software). For example, to see this feature in action, click on “David Aldridge” in the list, then click on the comment feed at the and of each post to read the comments (if they exist of course).

Oh! The wonders of Javascript! (more…)

Filed in Oracle, Technology with 2 Comments | Tags: ,


Cool Undocumented SQL Function SYS_OP_MAP_NONNULL and Some Alternatives

In Oracle, NULL does not equal NULL:

  EDDIE@XE> SELECT 'hi there'
    2    FROM DUAL
    3   WHERE NULL = NULL;

  no rows selected

But sometimes, if not most of the times, you do want the condition NULL = NULL to return true. For example:

  EDDIE@XE> CREATE TABLE t (
    2  col1  VARCHAR2(10),
    3  col2  VARCHAR2(10));

  Table created.

  EDDIE@XE> INSERT INTO t VALUES ('monkey', NULL);

  1 row created.

  EDDIE@XE> INSERT INTO t VALUES ('monkey', 'chicken');

  1 row created.

  EDDIE@XE> INSERT INTO t VALUES ('monkey', 'monkey');

  1 row created.

  EDDIE@XE> INSERT INTO t VALUES (NULL, 'monkey');

  1 row created.

  EDDIE@XE> INSERT INTO t VALUES (NULL, NULL);

  1 row created.

  EDDIE@XE> COMMIT;

  Commit complete.

  EDDIE@XE> SELECT NVL (col1, 'I am null') col1,
    2         NVL (col2, 'I am null') col2
    3    FROM t;

  COL1       COL2
  ---------- ----------
  monkey     I am null
  monkey     chicken
  monkey     monkey
  I am null  monkey
  I am null  I am null

Now, I want to select all the records from table t where col1 equals col2:

  EDDIE@XE> SELECT NVL (col1, 'I am null') col1,
    2         NVL (col2, 'I am null') col2
    3    FROM t
    4   WHERE col1 = col2;

  COL1       COL2
  ---------- ----------
  monkey     monkey

As expected, the row that has NULL in both col1 and col2 was not returned. You want this record returned. Here is how you can do it:

Using the undocumented function SYS_OP_MAP_NONNULL:

This function has been around for a while, but is still undocumented as of the latest Oracle database release (10gR2). Being undocumented means that it should not be used in production code, but it does not hurt to know that it exists and explore how it works. This function makes it possible to have NULL = NULL:

  EDDIE@XE> SELECT sys_op_map_nonnull (NULL)
    2    FROM DUAL;

  SY
  --
  FF

  EDDIE@XE> SELECT 'hi there'
    2    FROM DUAL
    3   WHERE sys_op_map_nonnull (NULL) = sys_op_map_nonnull (NULL);

  'HITHERE
  --------
  hi there

  EDDIE@XE> SELECT NVL (col1, 'I am null') col1,
    2         NVL (col2, 'I am null') col2
    3    FROM t
    4   WHERE sys_op_map_nonnull(col1) = sys_op_map_nonnull(col2);

  COL1       COL2
  ---------- ----------
  monkey     monkey
  I am null  I am null

Using simple logical operators:

  EDDIE@XE> SELECT NVL (col1, 'I am null') col1,
    2         NVL (col2, 'I am null') col2
    3    FROM t
    4   WHERE (col1 = col2 OR (col1 IS NULL AND col2 IS NULL));

  COL1       COL2
  ---------- ----------
  monkey     monkey
  I am null  I am null

Using DECODE:

  EDDIE@XE> SELECT NVL (col1, 'I am null') col1,
    2         NVL (col2, 'I am null') col2
    3    FROM t
    4   WHERE DECODE (col1, col2, 'match', 'no match') = 'match';

  COL1       COL2
  ---------- ----------
  monkey     monkey
  I am null  I am null

Using NVL:

  EDDIE@XE> SELECT NVL (col1, 'I am null') col1,
    2         NVL (col2, 'I am null') col2
    3    FROM t
    4   WHERE NVL (col1, 'impossible value') = NVL (col2, 'impossible value');

  COL1       COL2
  ---------- ----------
  monkey     monkey
  I am null  I am null

Of course, in this case, you have to be absolutely, positively 100 % sure that col1 and col2 will never have a value of ‘impossible value’ in them. Moreover, instead of NVL, you can also use similar functions.

Sources and Resources:

Filed in Oracle, Tips with 8 Comments | Tags: , , ,


Northwest Oracle Users Group (NWOUG) 2006 Fall Conference

When was the last time you did not use a computer for one full day? My last time was yesterday and it was not because I was on vacation. Yesterday, I was in the Northwest Oracle Users Group (NWOUG) 2006 Fall Conference.

I attended six 45-minute presentations. The sessions that were interesting and that I liked most were the one presented by Dan Morgan: The Hidden Jewels in 10g, and the one presented by Cary Millsap: Accountability for System Performance. Dan did not use PowerPoint (which is good because I do not like watching slides while at the same time listening to the presenter reading the slides, I like the “real” thing), he actually fired up his SQLPlus and demonstrated a few really cool, useful and some undocumented Oracle 10g SQL features, which I will be blogging about soon. I also liked Cary Millsap’s presentation mainly because the subject that he talked about was really interesting.

In the conference, I also bumped into Jared Still. Jared and I used to work for the same company before we both moved on to different employers, but still in the same neighborhood. Even though we worked for the same employer, we were not in the same department. After all, Jared is a DBA and I am a developer :) .

Filed in Oracle with 2 Comments | Tags: , ,


links for 2006-09-15

Filed in Links with Comments Off | Tags:


Oracle PL/SQL Guru Steven Feuerstein Wants to Meet With President Bush

Steven Feuerstein, the Oracle PL/SQL guru and author of many PL/SQL books, has a goal: to meet with president Bush. To that end, Steven has started a new blog titled: “Meet with Me, Mr. President!”. He describes his new blog as one that:

will chronicle my efforts to meet with President Bush, to take his measure as a man and human being. I encourage others to follow my path and request such a meeting!

On August 08, 2006, Steven faxed a letter to the White House scheduling office asking to meet with the president. Here is an excerpt from the letter:

… If I had nothing to go by except for the newspapers, television and blogs, I would have to conclude that you are very friendly, but not very intelligent. People make fun of the way you talk, and your command of the English language. They say that you are a puppet pulled by Vice President Dick Cheney’s strings. They say you would rather take another vacation with your dog than actually buckle down to the tough business of running the wealthiest, most powerful country in the world….I would like to meet with you so that I can experience first-hand your intelligence, compassion, sense of humor, and leadership…

Good luck Steven! I will be following your journey to the White House.

Check out Steven’s new blog at meetwithmemrpresident.blogspot.com/

Filed in Interesting Stuff, Oracle with 8 Comments | Tags:


Screencasts: Cracking WEP, Tunneling Exploits and More

I stumbled upon this website which has the following interesting screencasts demonstrating the use of a penetration testing tool for Linux:

(IE may not display the screencasts correctly. Best viewed in Firefox)

It also has this interesting, and rather disturbing, animated GIF image:

click to see it in action

And finally, a web page that crashes your system, especially if you open it up in an outdated web browser:

_____ DO NOT CLICK HERE _____

If you are still curious about what that web page does, here is the HTML code (may still crash your system if using IE – open it at your own risk).

Here is what I think, in order to fully protect your system from all of these exploits and attacks you have got to learn all of these hacking techniques and tools. To outsmart “bad” hackers, you have to be a “good” hacker yourself.

Filed in Interesting Stuff, Technology with Comments Off | Tags: ,


Quick Tip: Add More Destinations to the “Send To” in Windows

In Windows, there is this handy “Send To” option when you right click on a file or folder in Windows Explorer. In case you do not know, you can add more “places” to the list of where you can send a file or a folder to. Here is how you can do that. (more…)

Filed in Technology, Tips with 1 Comment | Tags: