Page 1 of 1

How to debug or get SQL statement?

Posted: Mon 13 Jun 2011 14:23
by jlentrichia
I'm doing what should be inserts but I'm getting a 'data too large for column' error. I can't figure out which column it's referring to so I'd like to see the generated SQL statement. Is it possible?

I'm using LinqConnect for Oracle.

Posted: Tue 14 Jun 2011 06:49
by Zero-G.
Hey

Of course you can do that.
For Example, before using the SubmitChanges Method, insert:

Code: Select all

yourDataContext.Log = Console.Out
yourDataContext.SubmitChanges
Than you can see the SQL and the InputData in the Console.

Hope this will help

Posted: Tue 14 Jun 2011 15:54
by StanislavK
Thank you Zero-G.

Another way to trace the generated SQL is to use the dbMonitor application and the LinqMonitor component:
http://www.devart.com/linqconnect/docs/dbMonitor.html
http://www.devart.com/linqconnect/docs/LinqMonitor.html

single character bug

Posted: Tue 14 Jun 2011 16:14
by jlentrichia
It appears I found the problem. When a default value for a single character column (char(1)) in oracle the default value in the generated code is producing something like:

_XyzFlag = @"'N'";

This seems to be trying to insert the value as it is, with the tic marks. That would cause the error since you are trying to insert 3 characters into a 1 character length field. This might be a wide-spread default value bug.

In order to get the row inserted I am over-riding the default value in the object to be just "N".

-Joe

debugging

Posted: Tue 14 Jun 2011 17:57
by jlentrichia
Also - I must be missing something because I did the above and I don't see anything being written to the console outside of exceptions.

-Joe

Posted: Wed 15 Jun 2011 10:10
by Zero-G.
Hey

Maybe, you are right. - Because the error is thrown by creating the SQL Syntax.
So it is possible, that you don't see anything in the console

No

Posted: Wed 15 Jun 2011 17:29
by jlentrichia
The error is definitely being thrown from Oracle.

Posted: Thu 16 Jun 2011 05:08
by Zero-G.
How do you know this?

When the error is really thrown by the server, than you would have to see something in the console!
The way is: Generate a SQL Code out from your LinQ Syntax. When this is made correct, then show it in the console (when the .log is set) and then bring it to the server.

So, please post some Exception message here.

Posted: Thu 16 Jun 2011 10:18
by StanislavK
jlentrichia, could you please specify the exact version (including the build number) of LinqConnect (or dotConnect for Oracle) you are using? We couldn't reproduce the problem with default values on the latest 2.50.24 and 2.50.25 builds.

As for the problem with tracing the generated SQL, please specify the code you are executing and the corresponding console output.