Monday, April 6, 2009

Case expressions in oracle

Using Case expressions in oracle along side exists clause.

select (case when exists(select COLUMN from SCHEMA.TABLE where COLUMN='abc') THEN 1 when exists(select CODE from SCHEMA.TABLE2 where COLUMN='abc') THEN 2 ELSE 0 END) as returnvalue from dual;

Thursday, April 2, 2009

Location Based Services on J2me enabled phones.

Location information on a J2me enabled phone can be retrieved using JSR 179. This JSR provides a "Location Provider" class which can be instantiated by passing a "Criteria" object.
LocationProvider is more of a factory pattern where-in it returns an instance based on the available hardware to get location information, it could either be GPS device built into the mobile phone or a GPS device paired with the mobile phone using bluetooth, the later of course also requires support of optional JSR 82 for bluetooth communication.
Another way of getting location information in certain cities in India to read the "Cell Area Information" which is displayed on most mobile phones. Most carriers like Airtel broadcast the location information as "CBS - Cell Broadcast Service". This information can be read in a J2ME application using WMA apis.
An example of how to do the same can be found at -- http://www.ibm.com/developerworks/wireless/library/wi-extendj2me/