Re: Problem with DBD::DB2 on AIX.



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
.



Relevant Pages

  • Re: Really Baffled any clues as to what is going on?
    ... > I am working on a script, it has an input file of machine names. ... > Dim fstrLogFilePath ... > fstrInputFile = InputBox("Enter name of file containing machines to ...
    (microsoft.public.scripting.vbscript)
  • Re: Parse an input file using a Key value
    ... I have an input file in the following format getting repeated. ... I tried to achieve this task using the following script below but it is ... To tranpose certain rows into columns and sort by one of the ...
    (comp.unix.shell)
  • Re: Running a DOS program using Microsoft Command Shell
    ... needed are available by public FTP: ... and the input file is run.txt. ... missing the ESC character, since I don'y know how to feed ESC in this ... When instructed from shell script, the progam simply ignores all SendKeys. ...
    (microsoft.public.windows.server.scripting)
  • newbie problem - how do I get dll version & size?
    ... I have a bunch of machines on which I need to check .dll revisions. ... to write a simplescript to do this. ... Set objFSO = CreateObject ... Line 1 of my input file seems to be skipped. ...
    (microsoft.public.scripting.vbscript)
  • Re: Really basic data entry question [Beginner]
    ... Because if your teacher told you ... 'data script'. ... I've never once seen an input file that was laid out like ... ramps so that you can jump your car over a narrow river; ...
    (comp.lang.java.programmer)