in reply to DBD::DB2::st execute failed: Bind failed

From execute in DBI:

If any arguments are given, then execute will effectively call "bind_param" for each value before executing the statement. Values bound in this way are usually treated as SQL_VARCHAR types unless the driver can determine the correct type (which is rare), or unless bind_param (or bind_param_inout) has already been used to specify the type.

I think the more pertinent question is what is the statement you are accessing with $self->{sth_get}?

Replies are listed 'Best First'.
Re^2: DBD::DB2::st execute failed: Bind failed
by talexb (Chancellor) on Feb 18, 2010 at 17:47 UTC

    I'm using the query

    select session_id, ctime, atime, data from schema.session where sessio +n_id = ?
    and the describe table shows
    Column Type Type name schema name Length Scale Nulls --------------- --------- ------------------ -------- ----- ------ SESSION_ID SYSIBM CHARACTER 40 0 No CTIME SYSIBM INTEGER 4 0 Yes ATIME SYSIBM INTEGER 4 0 Yes DATA SYSIBM VARCHAR 1024 0 Yes
    It's pretty straightforward.

    Alex / talexb / Toronto

    Team website: Forex Chart Monkey, Forex Technical Analysis and Pickpocket Prevention

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

      To debug why not call bind_param(1, $session_id) yourself and omit it from execute (I don't really understand why you don't get a better error and this might help). I'd also try taking one chr off the end of the session_id as your ids are exactly 40 chrs and so is the field (so nothing wrong but try it).

      I certainly agree that there are no red flags in what you've posted. What happens when you sub the following for your execute command:

      my $sth = $self->{sth_get}; $sth->bind_param(1, $session_id) or die "Bind failure:" . $sth->errstr +; $sth->execute() or die "Execute failure:" . $sth->errstr;

      I'm also a little curious why the binding failure dies in the DBD code as opposed to bubbling up to the user as a simple execute failure. Not so curious as to go source diving, but still...