Parameter Not Found

The BETA tester's forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
royyu
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 17.10.2014, 15:56

Parameter Not Found

Postby royyu » 04.07.2016, 05:41

Hi,

ZEOS 7.2.0-beta on Delphi 2009 / Windows XP, PosgreSQL 8

It cause a problem, when i using this SQL

ZQuery1.Close;
ZQuery1.SQL.add('select * from sys_user = :user_id');
ZQuery1.ParamByName('user_id').AsInteger := 1; //Parameter 'user_id' not found
ZQuery1.Open;


No problem when using ZEOS 7.0.0-dev.

So i check the code, The ZTokenizer NextToken function has some different between 7.0.0 and 7.2.0

7.0.0 can separate by 'SPACE', but 7.2.0 can't

plz help for that, Thanks

miab3
Zeos Test Team
Zeos Test Team
Posts: 916
Joined: 11.05.2012, 12:32
Location: Poland

Re: Parameter Not Found

Postby miab3 » 04.07.2016, 13:26

Where is WHERE (and TableName)?

Michal

royyu
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 17.10.2014, 15:56

Re: Parameter Not Found

Postby royyu » 05.07.2016, 03:03

Hi Michal,

Sorry for typing wrong:
ZQuery1.Close;
ZQuery1.SQL.add('select * from sys_user where user_id = :user_id');
ZQuery1.ParamByName('user_id').AsInteger := 1; //Paramrter 'user_id' not found
ZQuery1.Open;

Table name is 'sys_user'

Best Regards,

marsupilami
Gold Boarder
Gold Boarder
Posts: 588
Joined: 17.01.2011, 14:17

Re: Parameter Not Found

Postby marsupilami » 05.07.2016, 11:06

Hello royyu,

I didn't have the time yet to check this in depth. What happens if you remove the _ from your parameter name? So have userid instead of user_id?
With best regards,

Jan

miab3
Zeos Test Team
Zeos Test Team
Posts: 916
Joined: 11.05.2012, 12:32
Location: Poland

Re: Parameter Not Found

Postby miab3 » 05.07.2016, 15:16

For me it works:

Code: Select all

 ZQuery2.Close;
 ZQuery2.SQL.Clear;
 ZQuery2.SQL.add('select * from kontra where "N_SKROC" = :n_skroc');
 ZQuery2.ParamByName('n_skroc').AsString := 'KIM';
 ZQuery2.Open;

ZEOS 7.2 svn 3910:
http://sourceforge.net/p/zeoslib/code-0/HEAD/tree/branches/testing-7.2/
Delphi XE2-Win32
PostgreSQL 9.3
Windows 10-64

Michal

kgizmo
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 14.05.2010, 10:16
Location: Poland

Re: Parameter Not Found

Postby kgizmo » 11.09.2016, 13:57

I have the same problem with version 7.2 3929. Or maybe not the same but I have the same error.
For "and (I.nazwa iLike :nazwaFiltr)" everything works fine, but for "'and ((B.nazwa iLike :nazwaFiltr) or (B.skrot iLike :nazwaFiltr)) '" I've got "Parameter not found". Maybe it's all about nasted brackets?

kgizmo
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 14.05.2010, 10:16
Location: Poland

Re: Parameter Not Found

Postby kgizmo » 11.09.2016, 14:45

Found it. It's not about nested brackets. It's a problem with escape character "\".
Examples (for PostgreSQL):

SQL.Text:='select field1||''\\n''||field2 from tab where 1=1 and (field3 iLike :param)';
Everything is OK with Params but I get "\n" string in the result text.

SQL.Text:='select field1||''\n''||field2 from tab where 1=1 and (field3 iLike :param)';
Parameter not found.

SQL.Text:='select field1||E''\n''||field2 from tab where 1=1 and (field3 iLike :param)'; \\the original (working before) code and suitable for PostgreSQL
Parameter not found.

I was using 7.2 3648 and there wasn't problems with that. Now my existing programs don't work.

Kamil

kgizmo
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 14.05.2010, 10:16
Location: Poland

Re: Parameter Not Found

Postby kgizmo » 12.09.2016, 20:18

OK, here is a solution for PostgreSQL. There have to be made changes in ZPostgreSqlToken.pas:

Code: Select all

procedure TZPostgreSQLQuoteState.GetQuotedString(Stream: TStream; QuoteChar: Char;
  EscapeSyntax: Boolean; var Result: String);
const BackSlash = Char('\');
var
  ReadChar: Char;
  LastChar: Char;
  QuoteCount: Integer;
  LastWasEscapeChar: Boolean;
begin
  LastChar := #0;
  Result := '';
  InitBuf(QuoteChar);
  QuoteCount := 1;

  LastWasEscapeChar := False;
  while Stream.Read(ReadChar{%H-}, SizeOf(Char)) > 0 do
  begin
    if ReadChar = QuoteChar then
      Inc(QuoteCount, Ord((not EscapeSyntax) or (not LastWasEscapeChar)))
    else
      LastWasEscapeChar :=(ReadChar=BackSlash) and (not LastWasEscapeChar); //False; //Kamil Giza comment False;

    if (LastChar = QuoteChar) and (ReadChar <> QuoteChar) then
      if QuoteCount mod 2 = 0 then begin
        Stream.Seek(-SizeOf(Char), soFromCurrent);
        Break;
      end;
    ToBuf(ReadChar, Result);
    if (LastChar = BackSlash) and EscapeSyntax then begin
      LastChar := #0;
      //LastWasEscapeChar := True; //Kamil Giza add comment
      //Dec(QuoteCount); nope that doesnt' work @all see the tests
    end
    else if (LastChar = QuoteChar) and (ReadChar = QuoteChar) then
      LastChar := #0
    else
      LastChar := ReadChar;
  end;
  FlushBuf(Result);
end;

marsupilami
Gold Boarder
Gold Boarder
Posts: 588
Joined: 17.01.2011, 14:17

Re: Parameter Not Found

Postby marsupilami » 19.09.2016, 17:53

Hello Kamil,

The patch has been applied. See Zeos 7.2 Rev. 3930. Thanks for your help.
With best regards,

Jan

Gallemar
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 09.11.2017, 09:26

Re: Parameter Not Found

Postby Gallemar » 09.11.2017, 09:30

I have a similar problem on mysql, can you help?

ertank
Junior Boarder
Junior Boarder
Posts: 30
Joined: 02.06.2017, 12:00

Re: Parameter Not Found

Postby ertank » 17.11.2017, 22:49

Gallemar wrote:I have a similar problem on mysql, can you help?

Hello Gallemar,

Information you provided is not enough to help you. Would you post your SQL statement you are having problem and your TZQuery.ParamChar value, please.

Thanks.
Ertan


Return to “ZeosLib 7.2 Betatest Forum”

Who is online

Users browsing this forum: No registered users and 1 guest