Howdy, Thanks in advance for any guidance you may be able to provide.
The following query throws error: could not determine data type of parameter $1 $1 contains a comma delimited list of column names. I can run the query on the CLI and it works. If I swap the question mark that is $1 in the query, with a static column list, the query works in perl. Presumably I should be able to pass a column list as a variable when preparing a statement, but apparently I'm not getting the type correct? Could somebody refer me to the correct type code to use with delimted list of columns? Or do I have to do this a different way? I would prefer the column list interpolate at prepare time, as it makes the function more portable IMHO. Note: the first function prepare()s when called with (1), the the second function populates a provided array with anonymous hashes, and returns the number of matching records. ### CODE ### use DBI qw(:sql_types) ; use DBD::Pg qw(:pg_types) ; sub _listrev { return $_[0]->{'_listrev'} unless $_[1] ; $_[0]->{'_listrev'} = $_[0]->{'db_handle'}->prepare("SELECT ? FROM $_[0]->{'_revtablename'} WHERE $_[0]->{'_recordidname'} = ? ORDER BY ? DESC OFFSET ? LIMIT ?") ; return 1 ; } sub listrev { # get paginated revisions of a record, return count my $self = shift ; my $rectainer = shift ; my $recordid = shift ; my $freccols = shift ; my $orderby = shift ; my $startrec = shift ; my $endrec = shift ; $self->{'_listrev'}->bind_param(1, $freccols, { 'pg_type' => 'PG_VARCHAR'}) ; $self->{'_listrev'}->bind_param(2, $recordid) ; $self->{'_listrev'}->bind_param(3, $orderby) ; $self->{'_listrev'}->bind_param(4, $startrec) ; $self->{'_listrev'}->bind_param(5, $endrec) ; return undef unless $self->{'_listrev'}->execute() ; my $foo = $self->{'_listrev'}->fetchall_arrayref({}) ; @$rectainer = @$foo ; @$foo = () ; return(scalar(@$rectainer)) ; } ## END CODE ## Thanks!