Hello gentlemen!
First, forgive my English!
I'm having a problem with 7.2.1-rc version that did not occur in version 7.1.4-stable: SQL statements containing strings with the "\" character.
For example, when opening a ZQuery with this SQL, the parameters are not replaced by values:
SELECT (
'VALUE1 = ' || :param1 || '\r\n' ||
'VALUE2 = ' || :param2
) AS my_text;
Generating, therefore, the following error:
ERROR: syntax error at or near ":"
LINE 1: SELECT ( 'VALUE1 = ' || :param1 || '\r\n' || 'VALUE2 = ' || ...
For it to work, I'm having to do this:
SELECT (
'VALUE1 = ' || :param1 || CHR(13) || CHR(10) ||
'VALUE2 = ' || :param2
) AS my_text;
This way works perfectly!
In 7.1.4 version, the first way also worked perfectly.
What I did was just upgrade to the 7.2.1-rc version. I did not ANY changes in the database settings and changed NOTHING in my application.
I've tried on and off the property "standard_conforming_strings" in ZConnection, but the problem persists.
Of course, if I replace this '\r\n' for this '\\r\\n', the error does not occur, but a line break is not generated.
Can someone help me?
Thank you very much!
Problems with the "\" character
-
- Fresh Boarder
- Posts: 5
- Joined: 04.06.2014, 14:24
- Location: Maringá, Paraná, Brasil
Re: Problems with the "\" character
Hello,
You didn't write what database server do you use. I had the same problem. I found solution for PostgreSQL. There have to be made changes in ZPostgreSqlToken.pas:
I will send it to ZEOS Team.
You didn't write what database server do you use. I had the same problem. I found 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;
Re: Problems with the "\" character
@ kgizmo, All
It looks like that your patch works (for Zeos 7.2 svn 3929 and PostgreSQL).
Michal
It looks like that your patch works (for Zeos 7.2 svn 3929 and PostgreSQL).
Michal
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: Problems with the "\" character
@All:
The patch has been applied. See Zeos 7.2 Rev. 3930.
With Best regards,
Jan
The patch has been applied. See Zeos 7.2 Rev. 3930.
With Best regards,
Jan
-
- Fresh Boarder
- Posts: 5
- Joined: 04.06.2014, 14:24
- Location: Maringá, Paraná, Brasil
Re: Problems with the "\" character
Sorry, I forgot to say: use PostgreSQL!
-
- Fresh Boarder
- Posts: 5
- Joined: 04.06.2014, 14:24
- Location: Maringá, Paraná, Brasil
Re: Problems with the "\" character
Thank you very much! I'll test right now!marsupilami wrote:@All:
The patch has been applied. See Zeos 7.2 Rev. 3930.
With Best regards,
Jan
-
- Fresh Boarder
- Posts: 5
- Joined: 04.06.2014, 14:24
- Location: Maringá, Paraná, Brasil
Re: Problems with the "\" character
Worked perfectly! Thank you very much!