Sunday, April 08, 2007

I hate single-quotes

When you use SQL, you must enclose string values with Single-Quotes.

This sounds fair and square.

Things get messy when your strings themselves contain single-quote. A new technique has been introduced by Oracle to circumvent the hurdles. However, before describing that solution, let me describe the problem and its classical solution before showing the enhancement

Example (let me start with the normal straight forward case)
If I am using Oracle SQL and I want to display the following text

The Customer said YES

Then

SQL> SELECT ' The Customer said YES ' AS title from dual;

TITLE
-----------------------
The Customer said YES

Now, if the output should read

The Customer said 'YES' -- The difference her is that YES is surrounded with single-quotes

In this case, you cannot simply expect to just add a single quote around YES and pray that things shall work fine. You will be confusing the hell out of the parser because it cannot tell which quotes are to be displayed or the quotes that end the string

I mean the following SQL is a NO NO situation

SQL>SELECT 'The Customer said 'YES' ' AS title from dual;

*ERROR at line 1:ORA-00923: FROM keyword not found where expected

Traditionally, we could use two consecutive single-quote around YES to tell the parser that this is not the end of the string but rather an actual single quote character that needs to be displayed

1* SELECT ' The Customer said ' 'YES' ' ' AS title from dual;

TITLE
------------------------
The Customer said 'YES'

This will become even messier, if the entire string needs to be surrounded by single quotes

'The Customer said 'YES' '

New Approach, The Q-quote mechanism
In this approach, you can define your Single-Quote character which enables you to specify q or Q followed by a single quote and then another character to be used as the quote delimiter.

i.e. I want to define a character that indicates the beginning of the string and the terminator of the string.
If, for example, you want to utilize # as the single quote mark, then this is what you need to do when you encounter the beginning of the string, write the letter q followed by a single-quote followed by # and when the string is finished you just add # followed by ' as shown below
AMMAR>SELECT q'# The Customer said 'YES' #' as TITLE from dual;
TITLE
-------------------------
The Customer said 'YES'
Ammar Sajdi

Saturday, April 07, 2007

Push the button, and feel the power!


Because I am so in loving with last minute packing, I almost always forget something. It could be anything, but I never miss what I forgot on the last trip, cuz my mind is so alert to packing what I missed the last time.
a few days back I flew to Oman for a two day business trip, and while on transit at Bahrain Airport, it flashed to my mind that I did not pack my traditional Gillette razor. While looking for a Gillette razor I found something new "A Gillette M3Power razor"

It is a manual razor with normal blades, but is equipped with a battery. What the hell is a battery for? If I still need to move my hand up and down to shave??
This is the charm of the 21st century,, The tip of the razor (where the blades are) vibrates.
I do not know what value this is adding to the shaving process?? the process is for sure a bit ticklish, noisy and feels weird!! As for the quality for shave, i am not decided.
It is also event driven, there is a push button that can trigger the vibration or stop it!
I don’t get it, Generation of shaving techniques since i started shaving and i can hardly note any difference!! What next! Laser guided shaving machine?

Ammar Sajdi

Salary Theorem

This theorem stipulates that the less you work, the more money you make
read on













Wednesday, April 04, 2007

Sunset



Ammar Sajdi

Dont miss this place

Jal3ad Again!


I visited Jal3ad again two weeks back with the company guys. This is the second visit, I wrote about my first visit to Jalad in my third blog post back in August 14th, 2005 http://oraclejo.blogspot.com/2005/08/blog-post.html . I liked it this time more because of the greenery that this area enjoys during spring, really breath taking views. I had to reduce the resolution to make the size of the images, which resulted in deterioration of image quality. The actual images and the acual scenes are much nices, but this should give you an idea

That is me by the way, Ammar














Warm! Warm! weather coming up!!

Be careful,

The three coming days are going to be really warm. Temperature could be toping 27 Degree in Amman

Tuesday, April 03, 2007

Jennifer Aniston on Oprah winfrey


Her father (Ioannis Anastassakis) is Greek and was born in the island of Crete. He was an actor himself. Jennifer Anastassakis spend her child in Greece and N.Y.
Tonight and on Oprah Winfrey Show, Jennifer put an end to all rumors and declared that she did not undergo any cosmatic surgical procedure of any kind (Jobs). Still, nevertheless, and at age of 38, looking as good as ever. (Brad Pitt must have gone out of his mind)
recently in 2007, she received People's Choice Award: Favorite Female Movie Star, The Break-Up

Sunday, March 25, 2007

Most expensive ITEM on Amazon

Mohamad a friend of mine sent me a link to Amazon, could anybody find an item more expensive than this item
http://www.amazon.com/exec/obidos/ASIN/B000NL8210/downandoutint-20
































































Palindrome !!!?

Palindrome is an English word. I am NOT resourceful when it come to English vocabulary. I thought this word is worth talking about.

I am an IT guy and most of my knowledge , including written and spoken languages, is tightly coupled to the IT domain (Tightly coupled is one example, where people talk about Tightly Coupled Multi-processor system).

Naturally, then, Palindrome, must have something to do with IT.

I was looking for a way to speed up retrieval of names from an Oracle database system based on some knowledge about the suffix of the name (letters at the end of the word). Normal indexing wont work since indexing is based on the prefix of the name (Like when you look up the phone no of a person using a phone book, you search by the leading part of the name and not the trailing part).

I wanted to try an old SYNTAX that i still remeber which is the Reverse Key index , in which, index entries are indexed by the trailing part. While this approach is not intended for my purpose and has its own usage, but to properly use such indexing method, I also need to reverse my search variable, for example

the original query is

SELECT * FROM EMP where ENAME like '%AMMAR'

it should become

SELECT * FROM EMP where ENAME like ' RAMMA%'

To make is easier for the programmers, i thought that it would be good to introduce a REVRSE function so the the second query would look like

SELECT * FROM EMP where ENAME like REVERSE '%AMMAR'

The REVERSE function takes care of resequencing the name.

So what does Palindrome have to do with this?

IF REVERSE (X) = X then X is a Palindrome

IF X reads the same backward or Forward then it satisfies the meaning of Palindrome
Actually, it does have to be a word , it also can be a whole sentence (Read the following sentecne backward "A man, a plan, a canal, Panama")

"Side note: the word has another medical meaning
A segment of double-stranded DNA in which the nucleotide sequence of one strand reads in reverse order to that of the complementary strand."
The longest Palindrome is believed to be tattarrattat , then detartrated

Some examples from the web

civic
rotator
EYE
level
madam
minim
refer
sagas
dad
did
تُوْت
خَوْخ

[phrases and sentences]
Do geese see God?
Was it Eliot's toilet I saw?
Murder for a jar of red rum.
Some men interpret nine memos.
Never odd or even.
12/02/2021

can you verify that the following is Palindromic
我愛媽媽,媽媽愛我
Anyone with more words that satisfy the Palindrome criteria?

Ammar

Friday, March 23, 2007

Most Expensive Capital in the Arab World

According to the Economist, it is Amman.

the EIU Worldwide Cost of Living Survey revealed that Amman is the most expesive city in the Arab World. The list goes as follows: (it seems that the survey did not actually cover all Arab Contries, as i cannot see Beirut in the list)

This year rank (last year rank) city

72 (70) Amman Jordan
79 (80) Casablanca Morocco
79 (71) Dubai UAE
85 (82) Abu Dhabi UAE
88 (87) Doha Qatar
98 (87) Riyadh Saudi Arabia
103 (95) Kuwait City Kuwait
103 (93) Muscat Oman
109 (100) Jeddah Saudi Arabia
111 (104) Al Khobar Saudi Arabia
116 (113) Cairo Egypt
118 (115) Damascus Syria
123 (115) Algiers Algeria
126 (122) Tripoli Libya

as the ranking shows, Amman stands at position no 70,
Intresting, no American city is among the top 25 most expensive city

1 (1) Oslo Norway
2 (4) Paris France
3 (6) Copenhagen Denmark
4 (7) London UK
5 (2) Tokyo Japan
6 (4) Osaka Kobe Japan
6 (3) Reykjavik Iceland
6 (8) Zurich Switzerland
9 (12) Frankfurt Germany
9 (10) Helsinki Finland
11 (13) Seoul South Korea
12 (9) Geneva Switzerland
12 (11) Vienna Austria
14 (16) Milan Italy
14 (24) Singapore Singapore
16 (14) Hong Kong Hong Kong
16 (14) Munich Germany
18 (19) Berlin Germany
18 (16) Sydney Australia
20 (21) Brussels Belgium
20 (16) Dublin Ireland
20 (n/a) Nouméa New Caledonia
20 (21) Stockholm Sweden
24 (19) Melbourne Australia
25 (24) Lyon France

New York comes @28 just after Moscow.
Rome @31, Chicago and Montreal tie @36, San Francisco @41 , Toronto @43, Instanbul @53, Athens and Miami tie @55, Boston @63 (little hard to believe) ,Rio de Janeiro @79, Atlanta @84.

At the end of the list
123 (115) Algiers Algeria
124 (124) Asuncion Paraguay
125 (121) Dhaka Bangladesh
126 (n/a) Kathmandu Nepal
126 (122) New Delhi India
126 (122) Tripoli Libya
129 (126) Karachi Pakistan
129 (124) Mumbai India
131 (127) Manila Philippines
132 (128) Tehran Iran

From a world wide perspective we are almost in the middle.

Ammar Sajdi

6 degrees of seperation - what a small world

The 6 degrees of seperation is theory stating that any one on earth can reach another person on earth through a chain of acquintances that has no more than 5 poeple in between.
For example, if you want to send a gift to Madona, call somebody you think he/she knows madona! chances are she/he does not know her personally, but then again, that person shall try to contact another person. If the chain continues, the gift is bound to reach Madona after 5 links (contacts). Maybe one can try this through the Linked-In network as well.

The theory was first proposed in 1929 by the Hungarian writer Frigyes Karinthy in a short story called "Chains."

" In 1967, American sociologist Stanley Milgram devised a new way to test the theory, which he called "the small-world problem." He randomly selected people in the mid-West to send packages to a stranger located in Massachusetts. The senders knew the recipient's name, occupation, and general location. They were instructed to send the package to a person they knew on a first-name basis who they thought was most likely, out of all their friends, to know the target personally. That person would do the same, and so on, until the package was personally delivered to its target recipient.

Although the participants expected the chain to include at least a hundred intermediaries, it only took (on average) between five and seven intermediaries to get each package delivered. Milgram's findings were published in Psychology Today and inspired the phrase "six degrees of separation."

Read the original article

http://whatis.techtarget.com/definition/0,,sid9_gci932596,00.html

ammar sajdi

Fundamentals of Software Testing

Originally posted on jan , 23 2009, Published again on Sept,18,2024 extracted completely from    http://testingsoftware.blogspot.com/2005/1...