How to get sql error.

Hi,

I want to get sql error no &mesage and output to information when occur sql error.[:’(]

Is it possible to get sql error no &mesage in X++ ??

Regards,

Hi,

What do you mean by “to get SQL error” ? Do you run SQL native statements directly to SQL database through X++ code??

Janis

Hi Yuji,

Welcome to DUG [:)]

SQL statements and errors may be viewed from ‘SQL statement trace log’ form under System administration > Inquiries. And of course all SQL errors would be logged in SQL server Event viewer as well.

Hi,

Thank you for your reply.

for example…

Insert to a table via AOT class(X++) , but already exits same key record in the table.

AX display “Cannot create record - the record already exists.” in informationlog.

I want to display sql error no “2627” & error mesasge “Violation of PRIMARY KEY…” in informationlog. ex) “sql error. errNo:2627 / errMsg:Violation of PRIMARY KEY…”

Regards,

Hi Harish Mohanbabu ,

Thank you reply.

I konw… I think your reply is good !!

But our enduser want to confirm by informationlog .

Regards,

Hi Yuji,

It will be difficult to do this in standard AX without certain amount of programming. Even then, this will be quite challenging.

However you may want to try and test the standard functionality for this requirement -

  1. Under Tools > Options > SQL, turn ‘SQL trace’ on
  2. Switch Infolog option under Warnings on.

Please be aware you may end up receiving awful lots of SQL warnings.

Hi Harish Mohanbabu ,

I undarstand that it is difficult …

I’ll tell our customer & consider the other solution.

I apprisiate for you !! Have a nice weekend !![:)]

Best Regards,