$DB->do() doesn't return a statement handle ($sth) that you can use with
either $sth->bind_param() or $sth->execute(). Since the default type is
normally VARCHAR, you might not need to use {TYPE => SQL_VARCHAR}. You
probably want to do something like this:
$DB -> {RaiseErrors} = 1;
my $sth = $DB -> prepare("INSERT ... VALUES ( ?, ?, ? )");
while ( something ) {
# Get values
$sth -> execute( @values );
}
###
I don't use dbish, so I can't comment on that environment.
--
Mac :})
** I normally forward private questions to the appropriate mail list. **
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 18, 2002 18:12
Subject: How to use bind, AS/400 and DBD::ODBC questions
>
>
> Since we talking about bind, I'm have a fun time with it talking to
> an AS/400 DB2 via IBM's iSeries ODBC driver and DBD::ODBC on linux.
>
> Seems like any error kills the database connection and eval does
> not help. Does ODBC have a much harder time figuring out what to
> do with field types? I'm having to do this sort of thing:
> $i=1;
> $sth->bind_param($i++,'CADDR1',{TYPE=>SQL_VARCHAR}); #'CHAR(30)'
> $sth->bind_param($i++,'CADDR2',{TYPE=>SQL_VARCHAR}); #CHAR(30)'
> $sth->bind_param($i++,'CAUTH#',{TYPE=>SQL_VARCHAR}); #CHAR(6)'
> $sth->bind_param($i++,'CCARD#',{TYPE=>SQL_NUMERIC});
#NUMERIC(19)'
> Spelling it out to the last detail seems to help.
>
> Hell, I'm just trying to $DB->do(INSERT...) sql statements that work
> from dbish on command line, same drivers, same machine, same sequence.
>
> DB->trace() suggests that DBD::ODBC is looking for a cached table
> description which might make it easier. I'm thinking maybe
> SELECT * LIMIT 1 might give it that.... oops, no LIMIT 1 on AS400
> DB/2. Maybe SELECT * WHERE key='does_not_exist' will work. Perhaps
> dbish has those table descriptions where a vanilla tightly scoped
> $sth might not?
>
> I'll get there eventually, but if anyone has any experience to share
> with the oddities of this setup (me coming from UNIX background) I'd
> much appreciate it. It seems like it should not be this hard.