[patch_done] Input parameter count is less then expected

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

josimarz
Junior Boarder
Junior Boarder
Posts: 41
Joined: 14.09.2009, 17:29
Location: Brazil

[patch_done] Input parameter count is less then expected

Post by josimarz »

Hello!

I founded a error using TZQuery components:
Input parameter count is less then expected

In a Delphi Form, have two TZQuery components. The first component is named qryPessoas, with SQL property:

Code: Select all

SELECT * FROM PESSOAS
The PESSOAS table have the follows simplified structure:

Code: Select all

CD_PESSOA  INT(11)
NM_PESSOA  VARCHAR(60)
DT_NASCIMENTO  DATETIME
...
DS_ESTADO CHAR(2)
The TDataSource dsPessoas is linked with TZQuery qryPessoas.

The second TZQuery component of the Form is named qryMunicipios with SQL property:

Code: Select all

SELECT * FROM MUNICIPIOS WHERE UF = :DS_ESTADO
The simplified structure of MUNICIPIOS table:

Code: Select all

CD_MUNICIPIO  INT(11)
UF  CHAR(2)
DS_MUNICIPIO  VARCHAR(120)
The DS_ESTADO field of PESSOAS table is linked with UF field of the MUNICIPIOS table. Is a FOREIGN KEY.

When Open the TZQuery qryPessoas, the follows error is raised:
Input parameter count is less then expected

Debugging the component, checked that the error is raised in a follows code passage of the ZDbcMySqlStatement.pas unit (lines 395 - 474):

Code: Select all

function TZMySQLPreparedStatement.PrepareSQLParam(ParamIndex: Integer): string;
var
   ...
begin
  TempBytes := nil;
  if InParamCount <= ParamIndex then
    raise EZSQLException.Create(SInvalidInputParameterCount);
...
end;
This point, the InParamCount property is zero. However, the problem can be TZAbstractRODataset.SetStatementParams method of the ZAbstractRODataset.pas unit, in the follows code passage:

Code: Select all

if Param.IsNull then begin
         Statement.SetNull(I + 1, ConvertDatasetToDbcType(Param.DataType))
      end else begin
        case Param.DataType of
          ftBoolean:
            Statement.SetBoolean(I + 1, Param.AsBoolean);
          ftSmallInt:
            Statement.SetShort(I + 1, Param.AsSmallInt);
          ftInteger, ftAutoInc:
            Statement.SetInt(I + 1, Param.AsInteger);
          ftFloat:
            Statement.SetDouble(I + 1, Param.AsFloat);
          ftLargeInt:
            Statement.SetLong(I + 1, StrToInt64(Param.AsString));
          ftCurrency:
            Statement.SetBigDecimal(I + 1, Param.AsCurrency);
          ftString:
            Statement.SetString(I + 1, Param.AsString);
          ftBytes:
            Statement.SetString(I + 1, Param.AsString);
          ftDate:
            Statement.SetDate(I + 1, Param.AsDate);
          ftTime:
            Statement.SetTime(I + 1, Param.AsTime);
          ftDateTime{$IFNDEF VER130}, ftTimestamp{$ENDIF}:
            Statement.SetTimestamp(I + 1, Param.AsDateTime);
          ftMemo:
            begin
              Stream := TStringStream.Create(Param.AsMemo);
              try
                Statement.SetAsciiStream(I + 1, Stream);
              finally
                Stream.Free;
              end;
            end;
          ftBlob, ftGraphic:
            begin
              Stream := TStringStream.Create(Param.AsBlob);
              try
                Statement.SetBinaryStream(I + 1, Stream);
              finally
                Stream.Free;
              end;
            end;
        end;
This time, the DS_ESTADO parameter of the TZQuery qryMunicipios is typed as ftFixedChar, but ftFixedChar type don't expected for the CASE STATEMENT.

I changed the type of the fields DS_ESTADO and UF of the PESSOAS and MUNICIPIOS tables. Then the DS_ESTADO was typed as ftString.

I believe that the error can be fixed with the code change:

Code: Select all

ftString, ftFixedChar:
   Statement.SetString(I + 1, Param.AsString);
or...

Code: Select all

ftFixedChar:
   Statement.SetPChar(I + 1, Param.AsString);
Thank you!
Josimar Zimermann
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi,

Can you tell in what Delphi versio ftFixedChar was introduced? I have to use the right contitionals to make sure the code also compiles on D7 and fpc.

Matk
Image
josimarz
Junior Boarder
Junior Boarder
Posts: 41
Joined: 14.09.2009, 17:29
Location: Brazil

Post by josimarz »

Hello,

I could not identify which version was introduced the ftFixedChar data type.

I'm using Delphi 2006 version.

Josimar
josimarz
Junior Boarder
Junior Boarder
Posts: 41
Joined: 14.09.2009, 17:29
Location: Brazil

Post by josimarz »

Hello!

To solve the problem temporarily, in the field DS_ESTADO of the TZQuery qryPessoas, changed the property FixedChar to false.

I will create a project and submit to exemplify the problem.

Josimar
josimarz
Junior Boarder
Junior Boarder
Posts: 41
Joined: 14.09.2009, 17:29
Location: Brazil

Post by josimarz »

Hello!

I faked the error. Attached the sample project. Change the connection information in the component ZConnection.

The script example.sql installs the database and records.

After generating the error, change the FixedChar property of field AC_COUNTRY to False in the qryPersons TZQuery.

Delphi: 2006 version
SGDB: MySQL 5.0.45
You do not have the required permissions to view the files attached to this post.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Seems OK. ftFixedChar was already available in Delphi 5.

SVN Rev 843 (Testing branch)

Mark
Image
olehs
Zeos Dev Team
Zeos Dev Team
Posts: 118
Joined: 09.11.2009, 21:05

Post by olehs »

How about TZStoredProc? Shouldn't it be fixed too?
Oleg
olehs
Zeos Dev Team
Zeos Dev Team
Posts: 118
Joined: 09.11.2009, 21:05

Post by olehs »

By the way, the same error occurres, when passing Value as Variant of type ftByte (DELPHI12_UP)
Oleg
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

olehs,

Here we are talking about 6.6 which is not made for D12_Up. Switch to Zeos7. Is that issue equal present there?

Michael
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
olehs
Zeos Dev Team
Zeos Dev Team
Posts: 118
Joined: 09.11.2009, 21:05

Post by olehs »

EgonHugeist,

Sorry, didn't see the topic's branch.

But yes. I am using latest test branch version from SVN and
ftByte is not supported neither in TZAbstractRODataset nor in TZStoredProc.

An error occurs just when you execute something like

Code: Select all

ZQuery1.SQL.Text := 'select * from orders where id = :id;';
ZQuery1.ParamByName('id').Value := 1;
ZQuery1.Open;
Should I create a separate topic in 7.0?
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

olehs,

Oh it might be possible you miss the latest updates. We've been moved on sf.net.

New download URL: http://svn.code.sf.net/p/zeoslib/code-0 ... es/testing

so in 157x i did fix all missing D12_UP types like ftShort, ftByte, ftLongword etc also i fixed the wrong defined BIT type for MySQL..

Please verify the issue again.

Michael
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
olehs
Zeos Dev Team
Zeos Dev Team
Posts: 118
Joined: 09.11.2009, 21:05

Post by olehs »

Yes, I just saw it.

But there is no fix for TZStroredProc, and I don't think it's right to treat ftByte just like ftBytes.
ftByte is more like Integer field.

Code: Select all

        {$IFDEF DELPHI12_UP}
        ftByte:
          Statement.SetByte(I + 1, Param.AsByte);
        {$ENDIF}
olehs
Zeos Dev Team
Zeos Dev Team
Posts: 118
Joined: 09.11.2009, 21:05

Post by olehs »

olehs wrote: ftByte is more like Integer field.

Code: Select all

        {$IFDEF DELPHI12_UP}
        ftByte:
          Statement.SetByte(I + 1, Param.AsByte);
        {$ENDIF}
Sorry, I'm not catching up with you. It's already fixed )
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

olehs,

Uff your're right i forgot to fix that on th TZStoreProcedure too. I fixed this in two places on the AbstractRODataset and on the TZSQLProzessor.

But this is slighlt a messy stuff. Would be better to introduce a procedure in the ZDataSetUtils unit where i've to fix it only once.

Thank you for your hint so click update tomorrow or tonight and you got your missing patch, ok?

Michael
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
olehs
Zeos Dev Team
Zeos Dev Team
Posts: 118
Joined: 09.11.2009, 21:05

Post by olehs »

EgonHugeist,
Ok, thanks a lot.
Oleg
Post Reply