Am facing problem when using SQL components. A normal Delphi function which returns string didn’t resulted in AV. Am attaching the call stack as requested.
I tried all the possible ways and finally when i changed the return value of the function GetQueryText to integer , then the self parameter has value i.e., not nil and no AV.
your testcase seems incomplete, for example, you have FSQLConnection variable in login-pre.pas, but it isn’t initialized at all. it also can be a reason for failure …
can you use standard ADO/FireDAC/IBX/DBX/etc db components and create full qualified testcase that will show that PS works incorrectly, pls?
I just gave the outline for understanding, not the project am working with. In my project everything was initialized and perfect.
There was one more function returns Boolean which uses SQL, in that function i can see the self attribute contains all the stuff i.e., not null.
CL: TPSRuntimeClassImporter;
..
with CL.Add(TSQLQuery) do //<<<<<<<< cl = nil here
begin
RegisterConstructor(@TSQLQuery.Create, 'Create');
RegisterMethod(@TSQLQueryGetQueryText, 'GetQueryText');
end;
also update code as
// Compiler.
if not Compiler.Compile(script) then
// Compile the Pascal script into bytecode.
begin
// <------------- begin block
s := '';
for I := 0 to Compiler.MsgCount - 1 do
s := s+sLineBreak+Compiler.Msg[i].MessageToString;
showMessage(s);
// <-------------- end block
Compiler.Free;
// Compiler.
// You could raise an exception here.
Exit;
end;
it will show errors with PS code inside login-pre.pas
I am unable to send you my functioning code since it involves certain sensitive information, without which I am unable to provide you with a complete working sample. You can see that there is a function in my previous example: AV is provided by the function TSQLQueryGetQueryText(Self: TSQLQuery): String, which returns a string. I don’t have AV if the identical method returns an integer.
Yeah, I want to return sql.text. In the provided example , there is no sensitive info., but in order to provide you the working example then the problem arise.