Oracle Case versus Decode function

There is an equivalent Oracle function for the ANSI CASE function – it is called DECODE in Oracle. Both of them operate on data that has been retrieved from the database and consequently there is a need to reduce the number of rows that are to be retrieved with the help of the WHERE clause. As for any post-processing action, this would add cycles to any SQL query where either one of these statements are used in.

The other difference between the two is that CASE is an ANSI SQL standard and is portable across the different database vendors.

The following are equivalent examples of the CASE and DECODE functions based on the Oracle sample HR schema.

CASE:

SELECT country_name, CASE region_id WHEN 1 THEN ‘EUROPE’ WHEN 2 THEN ‘SOUTH AMERICA’ WHEN 3 THEN ‘AUSTRALIA’ ELSE ‘UNKNOWN’ END CONTINENT
FROM   countries; 

DECODE:

SELECT country_name, Decode(region_id, 1,’EUROPE’, 2,’SOUTH AMERICA’, 3,’AUSTRALIA’, ‘OTHER’) CONTINENT
FROM   countries;

Credit Cards and Luhn’s algorithm

Credit Card numbers – for most of the major players in the field – can be validated by the Luhn  algorithm. So when you enter a dummy credit card number for testing such as 4111111111111111 for VISA, suffice to say it can be validated by an implementation of Luhn Algorithm. Consequently before the credit card number is sent across the network for validation, it can be validated locally as well reducing expenses and latency.

For more information and sample implementations of Luhn Algorithm in various languages, please refer to the wiki page on Credit Card numbers.

netstat on linux

Coming from BSD, it so seemed that netstat -a would do the trick. However when I was running Active MQ, the console told me that port 8161 was being used but somehow netstat was not confirming that.

 Scratched my head, did a "man netstat" and it so figures that if the address cannot be resolved then that entry was not displayed. The answer is to perform;

netstat -anp =>that will take care of displaying 8161.