ASE SP order of parameter creation

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
derekwildstar
Posts: 32
Joined: Sun 01 Apr 2012 14:12
Location: Olinda / PE / Brasil
Contact:

ASE SP order of parameter creation

Post by derekwildstar » Tue 26 May 2015 20:44

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)

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: ASE SP order of parameter creation

Post by AlexP » Thu 28 May 2015 09:42

Hello,
We bind parameters by index in ODBCUniProvider. We will consider the possibility to add binding by name.

derekwildstar
Posts: 32
Joined: Sun 01 Apr 2012 14:12
Location: Olinda / PE / Brasil
Contact:

Re: ASE SP order of parameter creation

Post by derekwildstar » Thu 28 May 2015 23:30

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)?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: ASE SP order of parameter creation

Post by AlexP » Wed 03 Jun 2015 09:32

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.

Post Reply