On Mon, Apr 19, 2004 at 02:25:41PM -0700, Dean Arnold wrote: > > On Mon, Apr 19, 2004 at 05:16:02PM +0200, Bart Lateur wrote: > > > 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? > > > > Sadly not. The plan is for a ParamTypes attribute like ParamValues. > > Patches welcome. > > > > Tim. > > Now I'm confused. Are we talking about the same processing here ?
Ah, no. I confused this with a different issue that came up a while ago. > 1. The app wants to use the output of a prior execute()'s result > set as the values for another $sth's parameter attributes. In that case, > the example given should work (with the possible exception that > PRECISION and SCALE need to be specified as well), eg, > copying a table from one database to another. I doubt any drivers have a bind_param() method that pays attention to PRECISION and SCALE attributes. On the other hand, it should be harmless to pass them. More generally it's not clear that any given $sth->{TYPE} value for output can be used as a TYPE value for bind_param(). It would certainly be good if that were the case, but currently it's not mandated. I'll make a note to consider this in relation to DBI v2. > 2. The app wants $sth2 to "inherit" the placeholder attributes from > $sth1's placeholders. I believe this is the issue Tim is addressing, > and which is not currently supported....correct ? Correct. Tim.