Viewer.php and Stored Procedure parameters

Stimulsoft Reports.PHP discussion
Post Reply
jkrassman
Posts: 17
Joined: Sun Dec 09, 2018 8:56 am

Viewer.php and Stored Procedure parameters

Post by jkrassman »

Hi,

I am designing my report and it just works fine in the designer with the parameters. Then when I "Publish" my project and all the files are done, it seems to be missing the code to handle my paramaters?

This is the index.php file

Code: Select all

<?php
require_once "stimulsoft/helper.php";
?>
<!DOCTYPE html>

<html>
<head>
	<title>Report.mrt - Viewer</title>
	<link rel="stylesheet" type="text/css" href="css/stimulsoft.viewer.office2013.whiteblue.css">
	<script type="text/javascript" src="scripts/stimulsoft.reports.js"></script>
	<script type="text/javascript" src="scripts/stimulsoft.viewer.js"></script>

	<?php
		$options = StiHelper::createOptions();
		$options->handler = "handler.php";
		$options->timeout = 30;
		StiHelper::initialize($options);
	?>
	<script type="text/javascript">
		function Start() {
			Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile("localization/sv.xml", true);

			var str = Stimulsoft.System.IO.File.getFile("reports/Report.mrt");
			var report = new Stimulsoft.Report.StiReport();
			report.load(str);

			var options = new Stimulsoft.Viewer.StiViewerOptions();
			var viewer = new Stimulsoft.Viewer.StiViewer(options, "StiViewer", false);

			viewer.onBeginProcessData = function (args, callback) {
				<?php StiHelper::createHandler(); ?>
			}

			viewer.report = report;
			viewer.renderHtml("viewerContent");
		}
	</script>
</head>
<body onload="Start()">
	<div id="viewerContent"></div>
</body>
</html>
And this is the handler.php

Code: Select all

<?php
require_once "stimulsoft/helper.php";

// Please configure the security level as you required.
// By default is to allow any requests from any domains.
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Engaged-Auth-Token");

$handler = new StiHandler();
$handler->registerErrorHandlers();

$handler->onBeginProcessData = function ($args) {
	return StiResult::success();
};

$handler->process();
Where and how should i provide my parameter @corpid?

Regards, Joakim
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Viewer.php and Stored Procedure parameters

Post by Lech Kulikowski »

Hello,

In the JS version, parameters are not supported. You can use variables instead of parameters in your query:
select * from Table where column = {Variable}

and then provide values for variables.

Thank you.
jkrassman
Posts: 17
Joined: Sun Dec 09, 2018 8:56 am

Re: Viewer.php and Stored Procedure parameters

Post by jkrassman »

Ok, but I am using stored procedures for a lot of my queries?

If i use the PHP version, will that support parameters?
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Viewer.php and Stored Procedure parameters

Post by Lech Kulikowski »

Hello,

Unfortunately, no. Only variables.

Thank you.
jkrassman
Posts: 17
Joined: Sun Dec 09, 2018 8:56 am

Re: Viewer.php and Stored Procedure parameters

Post by jkrassman »

Ok, so there is no solution to grab a stored procedure with a parameter to create a webreport?
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Viewer.php and Stored Procedure parameters

Post by Lech Kulikowski »

Hello,

You can use Variables in the query:
exec StoreProcName {Variable1}, {Variable2} ...

Thank you.
jkrassman
Posts: 17
Joined: Sun Dec 09, 2018 8:56 am

Re: Viewer.php and Stored Procedure parameters

Post by jkrassman »

I am using temp tables in my procedures and getting this error:

"Invalid object name '#tmp'."
jkrassman
Posts: 17
Joined: Sun Dec 09, 2018 8:56 am

Re: Viewer.php and Stored Procedure parameters

Post by jkrassman »

Found the solution, had to add:

IF 1=0 BEGIN
SET FMTONLY OFF
END

To my procs.
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Viewer.php and Stored Procedure parameters

Post by Lech Kulikowski »

Hello,

Thank you for the information.
Post Reply