Click here to get back home

Re: Problem with DBD::DB2 on AIX.

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Re: Problem with DBD::DB2 on AIX. Hemant Shah 09-20-2006
Get Chitika Premium
Posted by Hemant Shah on September 20, 2006, 2:10 pm
Please log in for more thread options


I forgot to mentions that the example shows 3 columns, but the actual table
contains 50 coulmns.

While stranded on information super highway 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 $ (";
> 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?
>
> --
> Hemant Shah /"\ ASCII ribbon campaign
> E-mail: NoJunkMailshah@xnet.com \ / ---------------------
> X against HTML mail
> TO REPLY, REMOVE NoJunkMail / \ and postings
> FROM MY E-MAIL ADDRESS.
> -----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
> I haven't lost my mind, Above opinions are mine only.
> it's backed up on tape somewhere. Others can have their own.

--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.

Similar ThreadsPosted
Problem with Net::FTP July 21, 2004, 12:40 pm
DBI - DBD-DB2 Problem - Please help June 2, 2005, 11:07 pm
Net::FTP->problem with put February 28, 2006, 2:11 am
net::telnet problem July 23, 2004, 6:46 pm
Lwp Post Problem September 1, 2004, 4:09 am
DBD-Pg installation problem September 20, 2004, 10:34 pm
SSL LWP Timeout problem September 21, 2004, 2:25 pm
Win32::API problem... May 25, 2005, 5:33 pm
mod_perl2 problem October 3, 2005, 8:02 am
Problem with DBD-mysql November 20, 2004, 2:34 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap