Automating binding the parameter type

From: Bart Lateur (bart.lateur_at_pandora.be)
Date: 04/19/04


To: dbi-users@perl.org
Date: Mon, 19 Apr 2004 17:16:02 +0200

I'm working on a next generation of a DBI abstraction module...

Sometimes it's necessary to specify the type of placeholder parameter,
like

        use DBI ':sql_types';
        $dbh = DBI->connect(...);
        $sth = $dbh->prepare(...);
        $sth->bind_param(1, undef, SQL_INTEGER);
        $sth->bind_param(2, undef, SQL_VARCHAR);
        $sth->execute($param1, $param2);

My question is, assuming I have fetched a

        $sth1 = $dbh->prepare(...);
        $sth1->execute();

on the same table, before, is it safe to do:

        for my $i (0 .. $#fields) {
            $sth->bind_param($i+1, undef, $sth1->{TYPE}[$i]);
        }

or are the values that the attribute TYPE holds, not compatible with
this?

-- 
	Bart.


Relevant Pages

  • Re: Automating binding the parameter type
    ... > I'm working on a next generation of a DBI abstraction module... ... > Sometimes it's necessary to specify the type of placeholder parameter, ... PRECISION and SCALE attributes, as well. ...
    (perl.dbi.users)
  • Re: Automating binding the parameter type
    ... > I'm working on a next generation of a DBI abstraction module... ... > Sometimes it's necessary to specify the type of placeholder parameter, ... Patches welcome. ...
    (perl.dbi.users)