Page 1 of 1

Problems with TOraSQL and CRLF

Posted: Mon 04 Aug 2008 18:03
by jfudickar
Hi,

i i try to execute the following statement with TOraSQL i've got an error:

begin
execute immediate 'begin
null;
end;';
end;

The problem is that the string inside execute immediate contains a crlf and this is not allowed.

Any Chance to fix this?

Greetings
Jens

Posted: Tue 05 Aug 2008 07:11
by Plash
Oracle SQL syntax does not allow CRLF inside normal string constants. But in Oracle 10 you can use the alternative quoting. For example:

Code: Select all

begin 
execute immediate q'[begin 
null; 
end;]'; 
end;

Posted: Tue 05 Aug 2008 07:35
by jfudickar
I know, that it's not allowed.

The problem is: you have a text editor and use the

Code: Select all

OraQuery.Sql := Memo.Lines; 
Assignment to assign the strings.

Then you got such a problem.

It's the same in your odac demo sample application.


What about changing the #13#10 to #10 using the ConvertEOL property of the session whenever a OraQuery Statement is executed.

Which other way exists to remove the #13 after a

Code: Select all

OraQuery.Sql := Memo.Lines;
Greetings
Jens

Posted: Tue 05 Aug 2008 08:20
by Plash
The current version of ODAC has special code that leaves CRLF in string constants as is. We think that using the ConvertEOL option in this code can break compatibitity with previous ODAC versions.

If you want we can send you changes to the ODAC source code that will enable replacing CRLF in string constants.

Posted: Tue 05 Aug 2008 08:32
by jfudickar
Hi Oleg,

yes please.

But what about adding an additional property.

I use the components to create/execute pl/sql code in the database.
And here it is realy important to fix this crlf problematic.

And to patch your software every time is not the best solution.

Greetings
Jens

Posted: Tue 05 Aug 2008 21:22
by jfudickar
The question is: how can i assign such a peace of code to a tOraSQL.SQL property without having crlf in the sql.

Greetings
Jens

Posted: Wed 06 Aug 2008 12:04
by Plash
In the next ODAC build we'll add the RemoveCRInStringLiterals global variable to the OraClasses unit. You can set it to True in the initialization section of any of your units.

initialization
RemoveCRInStringLiterals := True;

I have send the changes to OraClasses.pas to your e-mail.