Oracle date format and Perl

Oracle has its own date format – DD-MM-YY (24-sep-09). So, to insert a value into Oracle date field you should somehow convert date from your format. Sure it can be done using some date/time module or your own function. But there are two simpler ways – set desire date/time format for session or use Oracle date conversion function.

To set specific date/time format for the session just run following query right after connection:
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
After that you may insert date such 2009-09-24 without any problems.

Another way is convert date to the Oracle format inside the query:
INSERT into some_table (d_start) VALUES (TO_DATE('2009-09-24 11:12:00', 'YYYY-MM-DD HH24:MI:SS'))

Both approaches work fine. But the first one is more appropriate if you use placeholders in your query.

Connect to Oracle DB from Perl script

After successful installation of DBD::Oracle it’s time to use it. The connection string is the same as for he rest DB:
my $dbi = DBI->connect("dbi:Oracle:$db_name:$db_host:$db_port", $db_user, $db_pass);
As result of running code above I got following error:
Couldn't connect to database db_name: ORA-12154: TNS:could not resolve the connect identifier specified (DBD ERROR: OCIServerAttach)
After googling I found that the problem was that. I tried to connect to the remove database but the driver couldn’t do that without special file – tnsnames.ora. It should be placed to the $ORACLE_HOME/network/admin and contain something like that:
db_name =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = db_host)(PORT = db_port))
)
(CONNECT_DATA =
(SERVICE_NAME = db_name)
)
)

And the connection string should be changed to use service name from the tnsnames.ora instead of host:
my $dbi = DBI->connect("dbi:Oracle:$service_name", $db_user, $db_pass);
Finally we should export variable ORACLE_SID into our environment. Add this command into .bashrc
export ORACLE_SID="orcl"
or set it using Perl variable $ENV:
$ENV{ORACLE_SID} = 'orcl';

See also

Installing DBD::Oracle under Fedora 11

Recently I got a task which needs to communicate with database Oracle from Perl. Perl has an excellent database abstraction interface DBI. But for specific database it needs a driver – DBD module. To install DBD::Oracle you have to perform following simple steps:

  1. Download and install oracle-instantclient11.2-basic and oracle-instantclient11.2-devel RPMs from Instant Client Downloads for Linux x86 page.
  2. Export ORACLE_HOME:
    export ORACLE_HOME=/usr/lib/oracle/11.2/client/
  3. Install DBD::Oracle using cpan shell or manually.

The most difficult part for me was installing Oracle client. Because navigation on the Oracle web site is not clear. Additionally you can install SQL*Plus package (oracle-instantclient11.2-sqlplus) to use Oracle shell for testing.

The RedHat Enterprise and CentOS users can use Perl-DBD-Oracle RPM to avoid separate Oracle client installation.

Nokia announced Qt Extended mobile platform

It seems that Nokia is going to produce a competitor of Android platform:

Nokia announced today the launch of Qt Extended 4.4, a complete mobile and embedded development platform based on the open source Qt toolkit. It is designed with a modular architecture that provides building blocks for assembling a Linux-based software stack for various embedded devices ranging from phones to set-top boxes.

Nokia already has a good experience with open software – see its Internet Tables family. Not sure who will be a winner – Android or Qt Extended. But any competition is definitely good for growth of mobile devices industry.

VMWare and kernel 2.6.24.X

Last week I upgrade my Fedora Core 8 to the latest stable kernel 2.6.24.3-12. As result the compilation of VMWare module vmmon gave that error:
/tmp/vmware-config1/vmmon-only/./include/compat_wait.h:60: error: conflicting types for ‘poll_initwait’
include/linux/poll.h:65: error: previous declaration of ‘poll_initwait’ was here
/tmp/vmware-config1/vmmon-only/linux/driver.c:172: warning: initialization from incompatible pointer type
/tmp/vmware-config1/vmmon-only/linux/driver.c:176: warning: initialization from incompatible pointer type
make[2]: *** [/tmp/vmware-config1/vmmon-only/linux/driver.o] Error 1
make[1]: *** [_module_/tmp/vmware-config1/vmmon-only] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.24.3-12.fc8-i686'
make: *** [vmmon.ko] Error 2
make: Leaving directory `/tmp/vmware-config1/vmmon-only'
Unable to build the vmmon module.

Solution is to use vmware-any-any-update116.
In my case I manually copied patched vmmon.tar, vmblock.tar and vmnet.tar to the /usr/lib/vmware/modules/source because script from vmware-any-any-update116 crashed by some reason.

Skype for Linux with video support

Skype for Linux

Recently I installed the latest Skype for Linux (2.0.0.43) on my both systems: Fedora 8 and Kubuntu 7.04. I was surprised because the video calls really work. We talked with one of my friends about 40 minutes (he uses Windows). The quality of sound and picture is good (we both have DSL Internet connection). Not sure how it’ll be for dial-up.

Currently I cannot test Skype with video on Nokia Internet Tablet. Because my N810 isn’t shipped yet from UK. Also I’m not sure that Skype development team built that version for Maemo.

Shuttle $199 Linux PC

Shuttle

Shuttle has announced a budget PC in compact form-factor with funny skins. Just for $199 you will get “an Intel Celeron processor, a 945GC chipset, 512MB of memory and either a 60GB or 80GB hard drive. What it won’t have: an optical drive or a PCI Express slot. Despite that, it’s a pretty good-looking box, and comes in red, blue, white, and black, each with a different icon stamped on the front.” It’s not bad, isn’t it? Also, the $99 barebones version is available to give to users the choice of CPU, memory and hard drive storage.

The new Shuttle KPC is based on Linux. So, it’s a good opportunity to step in the open source world!

[via eHomeUpgrade]

Accessing the Nokia N800 camera

Linux-based Internet Tablet Nokia N800 is very popular. Even coming N810 is not going to replace it completely (I’m not talking about windows-based Origami). Using Maemo SDK it’s fairly simple develop new applications or porting existing ones. For sure to be success you need a right documentation. Following article from IBM.com explains obviously how to use N800 camera API.

P. S. The easiest way IMHO to setup Maemo development environment is downloading the Maemo SDK VMware Appliance. It can be run with free VMwave Player which available for both: Linux and Windows.