What people have been saying in this thread is that you should seriously
consider using the placeholder/bind feature of DBI when you insert rows. If
you don't know the feature, learn it in the Perl doc. You'll write less code.
Let me try to explain this simply: when you use this feature, you don't need to
quote your data values, and therefore you don't need to know the data types of
the columns (usually). So that code you thought you needed to write to get the
data type and add quotes? You won't need to write that code.
For example:
# The problem here is: do you quote or don't quote?
# You have to add code here to add quotes around $val1 and $val2
# depending on the column type.
$sth->prepare("INSERT INTO tab (col1, col2) VALUES ($val1,$val2)");
$sth->execute();
# This is better. It doesn't matter what the type of the columns
# are. You never need to add quotes.
$sth->prepare("INSERT INTO tab (col1, col2) VALUES (?,?)");
$sth->execute($val1, $val2);
Depending on what you are doing, the placeholder/bind feature can solve several
other common database problems.
-----Original Message-----
From: Vamsi_Doddapaneni [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 14, 2005 7:27 AM
To: Thutika, Srinivas (ODC - Satyam)
Cc: [email protected]
Subject: RE: how to get datatype of columns of a table in perl script
Importance: High
Hi ,
Thanks for replying.
My problem is, the perl script successfully gets rows from oracle database
but I have to insert it into similar table in db2 i.e( x in oracle -> x in
db2) . For this I need to know the datatypes of columns (varchar, char,date
,timestamp) as these need quotes for insertion.
Hope you got my problem
Thanks & Regards
Vamsi