-my $offset = 0;
-my $limit = C4::Context->preference("SvcMaxReportRows") || 10;
-my ( $sth, $errors ) = execute_query( $sql, $offset, $limit );
-my $lines = $sth->fetchall_arrayref;
-my $json_text = to_json($lines);
-print $json_text;
+if ($sql) {
+ my $offset = 0;
+ my $limit = C4::Context->preference("SvcMaxReportRows") || 10;
+ my ( $sth, $errors ) = execute_query( $sql, $offset, $limit );
+ my $lines = $sth->fetchall_arrayref;
+ my $json_text = to_json($lines);
+ print $json_text;