How to debug or get SQL statement?

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
jlentrichia
Posts: 12
Joined: Wed 11 May 2011 15:12

How to debug or get SQL statement?

Post by jlentrichia » Mon 13 Jun 2011 14:23

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.

Zero-G.
Posts: 390
Joined: Sat 09 Dec 2006 12:20

Post by Zero-G. » Tue 14 Jun 2011 06:49

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

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 14 Jun 2011 15:54

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

jlentrichia
Posts: 12
Joined: Wed 11 May 2011 15:12

single character bug

Post by jlentrichia » Tue 14 Jun 2011 16:14

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

jlentrichia
Posts: 12
Joined: Wed 11 May 2011 15:12

debugging

Post by jlentrichia » Tue 14 Jun 2011 17:57

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

Zero-G.
Posts: 390
Joined: Sat 09 Dec 2006 12:20

Post by Zero-G. » Wed 15 Jun 2011 10:10

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

jlentrichia
Posts: 12
Joined: Wed 11 May 2011 15:12

No

Post by jlentrichia » Wed 15 Jun 2011 17:29

The error is definitely being thrown from Oracle.

Zero-G.
Posts: 390
Joined: Sat 09 Dec 2006 12:20

Post by Zero-G. » Thu 16 Jun 2011 05:08

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.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 16 Jun 2011 10:18

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.

Post Reply