Finding error position in statement

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Tokoloko
Posts: 2
Joined: Thu 04 Dec 2014 07:11

Finding error position in statement

Post by Tokoloko » Thu 04 Dec 2014 07:24

Hello,
I am currently working on a project where I replace the formerly used ODAC components by the UniDac components.
In the application is a possibility to check the syntax of a sql statement the user can enter. To do this I used the TOraQuery component, prepared the statement, and, in case of an exception, I could use the property ErrorOffset to find out where exactly (more or less) the error appeared.
Now I moved to TUniQuery (as the application should also support SQL server now), but I don't find something like the formerly used ErrorOffset. As there are a lot of classes (maybe TUniQuery is not ideal for that purpose) I might have overlooked something.

Kind regards,
Thorsten

Edit: Maybe I should add that I use UniDac 5.5

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Finding error position in statement

Post by AlexP » Thu 04 Dec 2014 11:42

Hello,

This feature is specific for Oracle, therefore it is implemented only in ODAC. However, when working with UniDAC and OracleUniProvider, you can use the following code for retrieving this value:

Code: Select all

Uses ..., OraClassesUni;

function ErrorOffset(DataSet: TCustomDADataSet): integer;
var
  v: variant;
begin
  TDBAccessUtils.GetICommand(DataSet).GetProp(prErrorOffset, v);
  Result := v;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  try
    UniQuery1.Open;
  except
    ShowMessage(IntToStr(ErrorOffset(UniQuery1)));
  end;
end;

Tokoloko
Posts: 2
Joined: Thu 04 Dec 2014 07:11

Re: Finding error position in statement

Post by Tokoloko » Thu 04 Dec 2014 11:58

Thank you, this works perfectly! :-)

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Finding error position in statement

Post by AlexP » Thu 04 Dec 2014 13:03

Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.

Post Reply