Page 1 of 1

[solved] parambyname asstring error

Posted: 15.06.2012, 15:27
by cfc
Hi,

I'm trying Zeos 7+delphi XE2+Firebird 1.5 and have a problem with parameters in query if is string, only de first character of string is received in firebird.

Example

Stored Procedure

begin
/* Procedure Text */
insert into TEST (VALOR, numero)
values (:VALOR, :numero);
texto=valor;
salida=numero;
suspend;
end

Query:

select *
from sp_test(:usr, :num)


ZQuery1.close;
ZQuery1.ParamByName('usr').AsString:='cfc';
ZQuery1.ParamByName('num').AsInteger:=9876;
ZQuery1.Open;

The query return:

c 9876

The field integer is correct, but the string is truncated.

Thankyou.

Posted: 15.06.2012, 16:37
by ism
Maybe
select * from sp_test(":usr", :num)

or

select * from sp_test(':usr', :num)

Posted: 15.06.2012, 21:54
by EgonHugeist
ism,

no that's terribly wrong. These are the Parameters which he assigns later... You can't quote them because they where handled as string instead of params afterwards.

cfc,

my first question is did you use the svn relases? And if yes then which one? Can you attach the ddl of sp_test too? Just to see how you assign the resultset you want to have..

Michael

Posted: 16.06.2012, 01:06
by cfc
I´ using the last version of svn.

The problem is in TZParamsSQLDA.EncodeString line 1801 of ZDbcInterbase6Utils.pas

In line 1824

Move(PAnsiChar(Str)^, sqldata^, sqllen);

I' declare variable s: RawByteString;
and change de line 1824

s := str;
Move(PAnsiChar(s)^, sqldata^, sqllen);

This works, but not what the best solution

Posted: 16.06.2012, 08:40
by EgonHugeist
cfc,

introducing the RawByteString was a good choise! But that solution isn't neutral compiler for all pascal compileres.

Can you switch to my branch? Just look here: http://zeos.firmos.at/viewtopic.php?t=3427
Tell me if the issue is the same. Actually that RawByteString is'n introduced in my branch too. My idea is to add a ZAnsiString = {$IFDEF DELPHI12_UP}RawByteString{$ELSE}AnsiString{$ENDIF} to the ZCompatibility.pas and use them in the whole Dbc-layer, where we need him.

So please test my branch and tell me if your issue is gone...

Michael

Posted: 27.06.2012, 20:33
by EgonHugeist
cfc,

thank you for confirmation, that this bug is solved on my branch.

Michael