Hi Piermaria,
There are many problems in supporting SQLWindows bind and into variables
(and expressions). We have developed our PPJ Framework as part our Porting
Project effort to port SQLWindows applications to .NET (C#) and we support
most Sql.* statements including bind and into variables and expressions. See
www.iceteagroup.com for more info.
The major problems are: scope, bind expressions, and bind controls. In
SQLWindows you can have sql statements like this: SqlPrepareAndExecute(h,
"select name from company into :m_company[getNext()].name"). The m_company
array can exist in any scope since your code might have called
SqlVarSetup(h) anywhere. The getNext() function (or a nIndex variable) can
also live anywhere, including a form, the global scope, or even
locals/parameters (which are impossible to access using reflection).
Additionally the bind variable can also be a control or a table column. To
make matter a bit more complicated, as you know, the scope can be changed
while fetching rows but calling SqlVarSetup() before the next
SqlFetchNext(). Sql statements can also be built dynamically by the
application (which is the most common case) and therefore it's very hard to
detect the variables involved. In order to support SQLWindows original code
we use a mini interpreter with a lot of reflection optimization to preserve
performance. It really required a lot of work.
The only other alternative is to re-engineer your application and use
ADO.NET parameters. Another problem you might face is that ADO.NET throws
exceptions (not normalized either, but specific to the database) while your
SQLWindows application uses When SQLError constructs which have no equal in
the OOP world. We replicated them either as try/catch blocks (which changes
the logic of the application) or as delegate error handlers (which preserves
the original logic but makes the code look a bit awkward).
--
Best regards,
Gianluca Pivato
--
Ice Tea Group, LLC
www.iceteagroup.com
Piermaria said:
Thanks for your answer.
I agree to cut the into clause of the sql statement.
But i don't understand how build the SqlPrepareAndExecute function.
It must have a variable number of paramters vh1,vh2,vh3,vh4, ... depending
from the number of fields extracting by the select. I could have a ParamArray
paramater but in .Net this is only byval and not byref. What do you think
about this ?
About multiple rows: for now we can ignore this problem because most of all
the select return only one row.
Piermaria