KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Creating a datastore causes an error. Why? #2829

Open Richb201 opened this topic on on Sep 20, 2022 - 4 comments

Richb201 commented on Sep 20, 2022

What is wrong with this report.php code? Am I having a naming issue?

       $sql="
        SELECT srat.taxyear as taxyear, srat.employee_email as employee_email, employee_title, srat.cost_center_name as cost_center_name, srat.consultant, srat.w2_wages,srat.reason, srat.qualified_dollars,srat.key_year
        FROM survey_results_activities_temp srat
        ";

        $this->src('substantiator')
            ->query($sql)
            ->pipe($this->dataStore("srat"))  ;

Richb201 commented on Sep 21, 2022

It seems that Mysql 8 is failing to create a temporary file. Therefore the above SELECT statement fails since survey_results_activities_temp doesn't exist. If the above query fails, I'd like to send the user to a "try later" page. Can I do a try/catch like below in a koolreport report file?

try{
$this->src('substantiator')
            ->query($sql)
            ->pipe($this->dataStore("srat"))  ;
}
catch
{go somewhere}
Richb201 commented on Sep 22, 2022

Can I break

       $sql="SELECT *
        FROM  BC_PR_list_temp as BPlt
       WHERE BPlt.taxyear='$taxyear' AND item<>'' AND type='BC'";

        $this->src('substantiator')
            ->query($sql)
            ->pipe($this->dataStore("BPlt_BC"))  ;

Into a separate query and pipe so i can see where the error is?

Sebastian Morales commented on Sep 26, 2022

You have to catch your sql error around $report->run() instead of pipe(). The pipe method in report setup just defines the data flow, there's no actual data processing there. If a report's run throws error you could create another report with a different sql query to show users.

Richb201 commented on Sep 26, 2022

Thx. I think that the create of temporary is what is failing. Hard to say since the CREATE TEMPORARY is not returning an error, the table is not created. I am using codeigniter 3.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None