Re: Problem with DBD::DB2 on AIX.
- From: "Mumia W. (reading news)" <paduille.4058.mumia.w@xxxxxxxxxxxxx>
- Date: Wed, 20 Sep 2006 10:29:04 GMT
On 09/20/2006 12:30 AM, Hemant Shah wrote:
Folks,
I am having problem with my perl script that uses DBD::DB2 and inserts
data into a table. I am trying to write a generic script that will
read table name, column name and data from a file and dynamically
build sql insert statement and insert data into the table.
The input file looks like:
tablename:col1,col2,col3
data1,data2,data3
data1,data2,data3
data1,data2,data3
.
.
.
.
The problem I have is that if I dynamically build the insert statement
then the data does not get inserted into the database and I do not get
any error. I intentionally wrong column name for one of the columns and
I do do not get any errors. If I hard code the insert statement and I get
error.
Here is how I build my statement:
# Build insert statement.
$InsStmt = "INSERT INTO ${TargetTableName} (";
my $ColumnsArraySize = @ColumnsArray;
for (my $i = 0; $i < $ColumnsArraySize; $i++)
{
if ($i == ($ColumnsArraySize -1))
{ $InsStmt .= $ColumnsArray[$i] . ")\n";
} else { $InsStmt .= $ColumnsArray[$i] . ", "; } }
$InsStmt .= "VALUES (";
for (my $i = 0; $i < $ColumnsArraySize; $i++)
{
if ($i == ($ColumnsArraySize -1))
{ $InsStmt .= "?);\n";
} else { $InsStmt .= "?, ";
} }
print "$InsStmt\n";
Output:
INSERT INTO DWH_PLIN (ACCESS_KEY, QUE_KEY, PLAN_CODE_TYPE)
VALUES (?, ?, ?);
If I hard code the statement as follows:
$InsStmt = "INSERT INTO DWH_PLIN (ACCESS_KEY, QUE_KEY, PLAN_CODE_TYPE)
VALUES (?, ?, ?);"
Then I get error that I should get.
What could cause this problem?
How do I solve it?
There is not enough code here to test why your script isn't erroring-out when you use bad fields.
Why don't you create a very small script that demonstrates the problem you are having?
I ran the script you posted, and it outputs the correct string, but it's more important to be able to reproduce the non-error that you're not getting when you attempt to insert into invalid fields.
--
paduille.4058.mumia.w@xxxxxxxxxxxxx
.
- Follow-Ups:
- Re: Problem with DBD::DB2 on AIX.
- From: Hemant Shah
- Re: Problem with DBD::DB2 on AIX.
- Prev by Date: Re: CPAN sees XML::Parser, require does not
- Next by Date: Re: Problem with DBD::DB2 on AIX.
- Previous by thread: Re: Problem with DBD::DB2 on AIX.
- Next by thread: Re: Problem with DBD::DB2 on AIX.
- Index(es):
Relevant Pages
|
|