Execute SQL Query in Report

Hello…
I have a PDF Report…
When i finish generation, save the Report as PDF, in the Code section, from Layout PDF

	$at_path=$this->Ini->path_doc;
	$doc_name = str_pad([Cod_InformeCaso], 8, "0", STR_PAD_LEFT);
	$filename = $at_path."-".$doc_name.".pdf";
	$pdf->Output($filename, "F");

Then, i need save this PDF in a blob fied…

$handle = @fopen($filename, 'rb');
if ($handle)
{
	$content = @fread($handle, filesize($filename));
	$content = bin2hex($content);
	@fclose($handle);
	$out = "0x".$content;
}
$q_blob = "Update InformesCasos Set PDFGenerado = 1, ArchivoPDF = $out Where Cod_InformeCaso = ".[Cod_InformeCaso];
sc_exec_sql($q_blob);
unlink($filename);

But sn error is showed to reach “Sc_Exec_SQL”
I’ts possible execute SQL from a report?

Thanks!!!

Solved. I call the report, and, from another button, save the report…