$dbh->{RaiseError} = $RaiseError;
$dbh->{PrintError} = $PrintError;
if ($@) { # To catch "Duplicate column name" caused by the derived table, or any other syntax error
- $sth = $dbh->prepare($sql);
- $sth->execute;
+ eval {
+ $sth = $dbh->prepare($sql);
+ $sth->execute;
+ };
+ warn $@ if $@;
# Loop through the complete results, fetching 1,000 rows at a time. This
# lowers memory requirements but increases execution time.
while (my $rows = $sth->fetchall_arrayref(undef, 1000)) {
return (undef, { queryerr => 'Missing SELECT'} );
}
+ foreach my $sql_param ( @$sql_params ){
+ if ( $sql_param =~ m/\n/ ){
+ my @list = split /\n/, $sql_param;
+ my @quoted_list;
+ foreach my $item ( @list ){
+ $item =~ s/\r//;
+ push @quoted_list, C4::Context->dbh->quote($item);
+ }
+ $sql_param = "(".join(",",@quoted_list).")";
+ }
+ }
+
my ($useroffset, $userlimit);
# Grab offset/limit from user supplied LIMIT and drop the LIMIT so we can control pagination
$dbh->do( 'UPDATE saved_sql SET last_run = NOW() WHERE id = ?', undef, $report_id ) if $report_id;
my $sth = $dbh->prepare($sql);
- $sth->execute(@$sql_params, $offset, $limit);
+ eval {
+ $sth->execute(@$sql_params, $offset, $limit);
+ };
+ warn $@ if $@;
return ( $sth, { queryerr => $sth->errstr } ) if ($sth->err);
return ( $sth );
sub GetReservedAuthorisedValues {
my %reserved_authorised_values =
map { $_ => 1 } ( 'date',
+ 'list',
'branches',
'itemtypes',
'cn_source',