function TOraSession.GetCompilationError(SQL: _string): _string;
Exists next text:
Code: Select all
Self.SQL.Text :=
'declare' + DALineSeparator +
'CURSOR Cur IS' + DALineSeparator +
'SELECT Line,Position,Text' + DALineSeparator +
'FROM All_Errors' + DALineSeparator +
'WHERE Name = :Name and Type = :Type' + DALineSeparator +
'ORDER BY Sequence;' + DALineSeparator +
'Rec User_Errors%ROWTYPE;' + DALineSeparator +
'StartPos INTEGER;' + DALineSeparator +
'EndPos INTEGER;' + DALineSeparator +
'begin' + DALineSeparator +
':Res := '''';' + DALineSeparator +
'for Rec in Cur loop' + DALineSeparator +
'if Rec.Line <> 0 or Rec.Position <> 0 then' + DALineSeparator +
':Res := :Res || RPad(Rec.Line || ''/'' || Rec.Position, 8);' + DALineSeparator +
'end if;' + DALineSeparator +
'StartPos := 1;' + DALineSeparator +
'EndPos := 1;' + DALineSeparator +
'while EndPos > 0 and StartPos <= Length(Rec.Text) loop' + DALineSeparator +
'EndPos := InStr(Rec.Text, Chr(10), StartPos);' + DALineSeparator +
'if EndPos > 0 then' + DALineSeparator +
'if EndPos <> StartPos then' + DALineSeparator +
'if StartPos > 1 then' + DALineSeparator +
':Res := :Res || RPad('' '', 10);' + DALineSeparator +
'end if;' + DALineSeparator +
':Res := :Res || LTrim(SubStr(Rec.Text, StartPos, EndPos - StartPos)) || Chr(13);' + DALineSeparator +
'end if;' + DALineSeparator +
'else' + DALineSeparator +
'if StartPos > 1 then' + DALineSeparator +
':Res := :Res || RPad('' '', 10);' + DALineSeparator +
'end if;' + DALineSeparator +
':Res := :Res || LTrim(SubStr(Rec.Text, StartPos)) || Chr(13);' + DALineSeparator +
'end if;' + DALineSeparator +
'StartPos := EndPos + 1;' + DALineSeparator +
'end loop;' + DALineSeparator +
'end loop;' + DALineSeparator +
'end;';
Self.SQL['Res'] := '';
Self.SQL['Name'] := ObjectName;
Self.SQL['Type'] := _UpperCase(ObjectType);
Self.SQL.Execute;
Please fix it:
1) Replace
Code: Select all
'FROM All_Errors' + DALineSeparator"
on
Code: Select all
'FROM sys.all_errors' + DALineSeparator"
2) Before set params values set params dataTypes, paramTypes and size (for fix problem with ORA-06502)
Code: Select all
...
'end loop;' + DALineSeparator +
'end;';
Self.SQL['Res'].datatype := ftString;
Self.SQL['Res'].ParamType := ptInputOutput;
Self.SQL['Res'].size := 32767;
Self.SQL['Res'] := '';
Self.SQL['Name'].datatype := ftString;
Self.SQL['Name'].ParamType := ptInput;
Self.SQL['Name'].size := 30;
Self.SQL['Name'] := ObjectName;
Self.SQL['Type'].datatype := ftString;
Self.SQL['Type'].ParamType := ptInput;
Self.SQL['Type'].size := 30;
Self.SQL['Type'] := _UpperCase(ObjectType);
Self.SQL.Execute;
3) You are always call GetCompilationError
Code: Select all
procedure TOraSQL.InternalExecute(Iters: integer);
begin
try
inherited;
except
on E: EOraError do begin
if E.ErrorCode = 24344 then
raise EOraError.Create(E.ErrorCode,
E.Message + TOraSession(UsedConnection).GetCompilationError(SQL.Text), E.Component);
raise EOraError.Create(E.ErrorCode, E.Message, E.Component);
end
else
raise;
end;
end;
but my application does not need this and at the same time very necessary speed of execution.
Please add the ability to avoid the query to all_errors. (don't call function GetCompilationError)