Archive for March 7th, 2007

Limiting query results in DB2. Replacing ROWID in Oracle

While working with DB2 tables, many times we may need to limit query results. This is especially true when we just want to test out our queries. If the data volume is huge, the queries can take hell lot of time.

In oracle, the solution is to use ROWID in WHERE clause. In DB2, you can use the construct FETCH FIRST 10 ROWS ONLY. For example,

SELECT * FROM CUSTOMER FETCH FIRST 10 ROWS ONLY;

A short story on “where there is a will, there is a way”

An old man lived alone in Minnesota. He wanted to spade his potato garden, but it was very hard work.

His only son, who would have helped him, was in prison. The old man wrote a letter to his son and mentioned his situation:

Dear Son,

I am feeling pretty bad because it looks like I won’t be able to plant my potato garden this year. I hate to misdo the garden, because your mother always loved planting time. I’m just getting too old to be digging up a garden plot. If you were here, all my troubles would be over. I know you would dig the plot, for me if you weren’t in the prison.

Love,
Dad

Shortly, the old man received this telegram:

“For Heaven’s sake, Dad, don’t dig up the garden! That’s where I buried the GUNS!!”

At 4 a.m. The next morning, a dozen FBI agents and local police officers showed up and dug up the entire garden without finding any guns. Confused, the old man wrote another note to his son telling him what happened and asked him what to do next. His son’s reply was:

“Go ahead and plant your potatoes, Dad It’s the best I could do for you from here.”

So the moral of the story is that “whatever situation you are in, you may be able to help someone in need”. Now it is a completely different question why such an intelligent fellow ended up in jail :)