ok, in MSSQL, I had a Stored Procedure defined as
SELECT ROW_NUMBER() OVER (ORDER BY Count(*)) AS ID,
1 AS BASVERSION,
GETDATE() AS BASTIMESTAMP,
ROStatus as Status,
ST.StaOrigCaption as Caption,
ST.Color ,
COUNT(*) AS Cnt
FROM RO
INNER JOIN STATUS ST ON RO.ROStatus = ST.ID
GROUP BY ROStatus, ST.StaOrigCaption, ST.Color
Having Count(*) < 300
Order by Cnt DESC
So I changed it to use this new method:
EXEC_SQL 'SELECT ROW_NUMBER() OVER (ORDER BY Count(*)) AS ID,
1 AS BASVERSION,
GETDATE() AS BASTIMESTAMP,
ROStatus as Status,
ST.StaOrigCaption as Caption,
ST.Color ,
COUNT(*) AS Cnt
FROM RO
INNER JOIN STATUS ST ON RO.ROStatus = ST.ID
GROUP BY ROStatus, ST.StaOrigCaption, ST.Color
Having Count(*) < 300
Order by Cnt DESC'
RETURN DASH_RO_Status_Counts
I'm not doing any field replacement here, but even if I was, I'm not sure of the advantage of this over using a SP.
A SP gets pre-compiled/analyzed by MSSQL and is supposed to perform better than an ad-hoc query.
And IF I NEEDED TO substitute some values in a WHERE clause, then I would do that in the SP anyway and I'd still have the benefits of a pre-compiled SP.
You know, traditionally Magic wasn't a SQL tool - for many years, many large systems were written using Btrieve.
I certainly would like to know a benefit to a Magic Programmer-now-turned-Aware Programmer of using this.
Just because Magic could do it (and now you have an influx of Magic architects investing into Aware in Europe who have expressed interest and motivated Aware to implement this) doesn't mean there's a real reason to do it.
Maybe the "magic guys" (and I'm one of them) who wanted this weren't that strong on doing Stored Procedures (example: Mark Bailey who does almost nothing in SQL) and this enables them to get their hands dirty a little bit. But by doing it this way, you're not writing portable code - the Syntax is going to be diff for MSSQL, MYSQL, Oracle, for example. And now you've got SQL code littered throughout Aware instead of all in one place in the back end.
I dunno, there's pros & cons, I'm sure.
But it still would be nice to know a real "business case" or Programming Problem this solves that already wasn't doable with Aware... rather than "the ex-Magicians-turned-Aware-Investors" requested it.