I try to run a query which contain local variable and loop. But Fusio/Doctrine return empty/error on execute.
example (empty result or boolean):
$sum = $connection->fetchAll("declare @dateFrom DATETIME=CONVERT(DATE, DATEADD(d, -( DAY(DATEADD(m, -1, GETDATE() - 2)) ), DATEADD(m, -1, GETDATE() - 1)));
declare @dateTo DATETIME=CONVERT(DATE, DATEADD(d, -( DAY(GETDATE()) ), GETDATE()));
declare @dateFromtmp DATETIME=@dateFrom;
declare @tmpDate table(Dates DATETIME);
WHILE (@dateFromtmp <= @dateTo)
BEGIN
insert into @tmpDate values(@dateFromtmp)
SET @dateFromtmp = DATEADD( DAY,1,@dateFromtmp)
END;
SELECT @dateFrom;
");
$type = "is " . gettype($sum);
$count = count($sum);
return $response->build(200, [], [
'type'=>$type,
'count'=>$count,
'summary' => $sum,
]);
returns:
{
"type": "is array",
"count": 0,
"summary": []
}
there is no problem to run below query:
$sum = $connection->fetchColumn("declare @dateFrom DATETIME=CONVERT(DATE, DATEADD(d, -( DAY(DATEADD(m, -1, GETDATE() - 2)) ), DATEADD(m, -1, GETDATE() - 1)));
declare @dateTo DATETIME=CONVERT(DATE, DATEADD(d, -( DAY(GETDATE()) ), GETDATE()));
declare @dateFromtmp DATETIME=@dateFrom;
declare @tmpDate table(Dates DATETIME);
SELECT @dateFrom;
");
$type = "is " . gettype($sum);
$count = count($sum);
return $response->build(200, [], [
'type'=>$type,
'count'=>$count,
'summary' => $sum,
]);
return :
{
"type": "is string",
"count": 1,
"summary": "2017-08-01 00:00:00.000"
}
I'm suspecting that this is related to the loop. Is there a way to run this query in Fusio.?
Thanks