Tuesday, December 28, 2010

Scope of the Perl special variables $1 to $9

 Perl contains local special variables $1 to $9.  These variables contains the sub patterns which are matched from the earlier pattern.  For example:

my $var="Perl is beautiful";
my $var1="Perl is beautiful";
$var =~ m/(\w+) (.*)/;
print "The first word is: ", $1, "\n";
print "The remaining part is: ", $2, "\n";

Thursday, December 23, 2010

How to prepare Oracle insert queries for data present in flat file

    In this article, we are going to see how to load text data present in a file into an Oracle table. Data can be loaded into an Oracle table from a flat file in  two ways:

1. Using SQL Loader.
2. By Preparing Insert queries.

 Let us discuss about the second method of preparing insert queries:

 Assume we have an EMP table in the Oracle database with the following fields:
EMP_ID          NUMBER(4)
EMP_NAME        VARCHAR2(20)
EMP_SAL         NUMBER(5)