I am trying to get the ADDM report for Oracle Database. The output is in an array fashion as a .txt. I need to display it in a table row format. I'm not getting the desired output however.
$today = date("His");
$taskname =$username.$today;
$taskquery = "BEGIN DBMS_ADDM.ANALYZE_INST(:tname, :bsnap,:esnap,:instnum);END;";
$stid = oci_parse($conn,$taskquery);
oci_bind_by_name($stid, ":tname", $taskname);
oci_bind_by_name($stid, ":bsnap", $bsnap);
oci_bind_by_name($stid, ":esnap", $esnap);
oci_bind_by_name($stid, ":instnum", $inst);
oci_execute($stid);
$mainquery = "SELECT DBMS_ADDM.GET_REPORT(:tname) from dual";
$stid = oci_parse($conn,$mainquery);
oci_bind_by_name($stid, ":tname", $taskname);
oci_execute($stid);
echo "<table border='1'>
";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo "<tr>
";
foreach ($row as $item) {
echo " <td>" . $item . "</td>
";
}
echo "</tr>
";
}
echo "</table>
";
Now this returns a error saying : Object of class OCI-Lob could not be converted to string
So I tried a var_dump after doing a oci_fetch_all on $stid, and got this:
array (size=1)
'DBMS_ADDM.GET_REPORT(:TNAME)' =>
array (size=1)
0 => string ' ADDM Report for Task...and rest of the report shows here'
How can I echo that string that shows the report, because it displays it in the proper format I would get it on a shell. This is for a front end UI purpose.
I got my answer on this question. So it turns out that shell_exec function of PHP does a fantastic job of doing a simple cat command of the txt file in Linux format. So I simply output the variable that displays the string, into a txt file, and simply shell_exec('cat filename')
So simple!!!