mario -- had another thought on this.   see below.  
 
In a message dated 2/17/2006 8:35:27 P.M. Eastern Standard Time, [EMAIL PROTECTED] writes:
 
> <quote who="[EMAIL PROTECTED]">
> >
> > In a message dated 2/17/2006 5:46:24 P.M. Eastern Standard Time,
> > [EMAIL PROTECTED] writes:
> >
> >> so .... why does it not work -- any ideas?
> >>
> >> <quote  who="Brian Raven">
> >> > Mario Sanchez <> wrote:
> >>  >> hello
> >> >>
> >> >> the following statement works  perfectly:
> >> >>
> >> >> $sth->bind_columns(\$f1data,  \$f2data, \$f3data);
> >> >>
> >> >> however, if i do  this
> >> >>
> >> >> $bind = "bind_columns(" . "\\" .  '$f1data, ' . "\\" . '$f2data, ' .
> >> >> "\\" . '$f3data)';
> >>  >> $sth->$bind;
> >> >>
> >> >> when i run the script  i get ...
> >> >> Can't locate object method "bind_columns(\$f1data,  \$f2data,
> >> >> \$f3data)" via package "DBI::st" at 2makexml.pl line  54.
> >> >>
> >> >> any suggestions????
> >> >
> >>  > Yes. Don't do that.
> >> >
> >> > Seriously though, what's  wrong with the statement that works
> >> perfectly.
> >> > I find it hard to  imagine what you are trying to accomplish that
> >> makes
> >> > you want to  try that. Perhaps you could explain.
> >> >
> >> > HTH
> >>  >
> >> > --
> >> > Brian Raven
> >
> >
> > it doesn't work because you are trying to create a soft reference to a
> > function named -- literally -- ``bind_columns(\$f1data, \$f2data,
> > \$f3data)''  and
> > then invoke it as a member function of whatever object $sth references,
> > and
> > such a function does not exist in any accessible namespace.
> >
> > try something like this (UNTESTED):
> >
> >    my $sth = something();
> >
> >    my $bind_statement = q[ $sth->bind_columns(\$f1data,  \$f2data,
> > \$f3data)
> > ];
> >
> >    my $result = eval $bind_statement;
> >
> > or like this (ALSO UNTESTED):
> >
> >    my $bind_parameters = q[ (\$f1data, \$f2data, \$f3data)  ];
> >
> >    my $result = $sth->bind_columns( eval  $bind_parameters );
> >
> > hth -- bill walters
 
here's another approach.   i don't know if speed is an issue for you, but if it is, you
may not want to pay the price of firing up the perl interpreter.   slices might do the trick
if you know beforehand the ordinal numbers of all the columns you're dealing with.  
 
(UNTESTED):  
 
   my @column_references = (
      \$f0data,   # is there a zeroth column?   use undef as placeholder if not.  
      \$f1data,
      \$f2data,
      \$f3data,
      \$f4data,
      \$f5data,
      \$f6data,
      );
 
   my $result = $sth->bind_columns( @column_references[ 1, 2, 3 ] );
slices are not confined to any particular order, so you could say something like  
 
   @column_references[ 4..6, 3, 2 ];
 
if necessary.   it's also easy to imagine a column number validation function that
could be used to form a list of column numbers to feed to the slice:  
 
   my @columns = validate_column_numbers( 1, 2, 3 );  
   my $result = $sth->bind_columns( @column_references[ @columns ] );
it would even be possible to eliminate the use of references to named scalars
in the @column_references array above and deal only in references to a particular
subset of elements of that array.   and so on...
 
just some thoughts -- bill walters  
 
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to