Page 1 of 1

ASE SP order of parameter creation

Posted: Tue 26 May 2015 20:44
by derekwildstar
Hello!

Here, at my workplace, we are using ASE 15.

Actually we are trying to convert some projects from BDE to UniDAC. Until now every single non-visual BDE component (TStoredProc) is being correctly "translated" to UniDAC however, there are one implementation where we are using a generic TStoredProc, i.e., we are using the component at runtime, setting the correct properties, creating the necessary parameters and doing an Open.

On BDE, the parameters creation can be made on any order, but now, we figured that UniDAC is using the parameters by their positions not by their names. We arrived at this conclusion when some codifications raised runtime errors asking for conversion from "varchar" to "integer". After some deep debug we saw that exchanging the order of creation of the parameters we achieved success.

Now the question: UniDAC does not uses the name of parameters to assign it before to call a procedure? We have this impression...

Code: Select all

    STPRAux.StoredProcName := 'dbo.p_select_unidade;1';

    with TParam(STPRAux.Params.Add) do
    begin
      Name := '@sigla';
      DataType := ftString;
      ParamType := ptInput;
      Value := Null;
    end;

    with TParam(STPRAux.Params.Add) do
    begin
      Name := '@codg';
      DataType := ftInteger;
      ParamType := ptInput;
      Value := Null;
    end;

    with TParam(STPRAux.Params.Add) do
    begin
      Name := '@dscr';
      DataType := ftString;
      ParamType := ptInput;
      Value := Null;
    end;

    STPRAux.Open;
The code above works, because the order of added parameters is the same of the procedure creation (below)

Code: Select all

CREATE PROC p_select_unidade (@sigla VARCHAR(20) IN, @codg  INT IN, @dscr VARCHAR(120) IN) 
Exchanging the second and first parameters raises an exception telling about conversion, because these parameters are integer and varchar and they are incompatibles, of course. So, something is being done erroneously?

Delphi 2006
UniDAC 4.1.6
ASE 15 (server) / ASE 12.5 (client)

Re: ASE SP order of parameter creation

Posted: Thu 28 May 2015 09:42
by AlexP
Hello,
We bind parameters by index in ODBCUniProvider. We will consider the possibility to add binding by name.

Re: ASE SP order of parameter creation

Posted: Thu 28 May 2015 23:30
by derekwildstar
Well,

Sad to know this, because all current code consideres the names of the parameters on our systems. Can you please say why this is done that way (a unusual "Delphi" way indeed)?

Re: ASE SP order of parameter creation

Posted: Wed 03 Jun 2015 09:32
by AlexP
For parameter binding, an ODBC API method SQLBindParameter is used, in which the parameter index is used. Therefore we didn't implement support for other methods for binding by name. As I have wrote earlier, we will try to support this feature in one of the following versions.