The argument for prepare is a SQL statement, not the name of a file.
Also, AFAIK, you can't prepare multiple statements at a time, only one at
a time (and including a ; may or may not work, depending on your platform;
I'm not DB2/DBI literate).

Have you gotten this to work?

$sth = $dbh->prepare("select * from foo");
$sth->execute();

For dump_results, you need to re-read the docs.  Your example isn't
anything close to what I see in 'perldoc DBI':

$rows = $sth->dump_results($maxlen, $lsep, $fsep, $fh);

Which, at a minimum, tells me you need to open and close 'genpak.sql'
yourself.

Finally, do() will do a prepare and execute on a single SQL statement.
So, if your goal is to generate a script and execute it, you need to write
your own wrapper to read, parse, and execute each statement.  Another
alternative is to create a stored procedure, and execute it, but I don't
think that's an option with DB2, is it?

HTH,
Dave


>
> Hi eveyone;
>
> Can someone help me with this: I am trying to do a prepare and execute a .sql when 
>connected to a DB2 database using DBI.  The foo.sql is the ($sqlfilename)has to 
>($genpak.sql)  here is the code:
>
> my $sth = $dbh->prepare($sqlfilename);
> $sth->execute();
> $rows = DBI::dump_results($sth,genpak.sql);
> $sth = $dbh->do($genpak);
>
>
> any help would be cool.Thanks
>
> Steve
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now

Reply via email to