How to debug or get SQL statement?

How to debug or get SQL statement?

Postby 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.
jlentrichia
 
Posts: 12
Joined: Wed 11 May 2011 15:12

Postby 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
Zero-G.
 
Posts: 390
Joined: Sat 09 Dec 2006 12:20

Postby 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
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

single character bug

Postby 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

Postby 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
jlentrichia
 
Posts: 12
Joined: Wed 11 May 2011 15:12

Postby 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
Zero-G.
 
Posts: 390
Joined: Sat 09 Dec 2006 12:20

No

Postby jlentrichia » Wed 15 Jun 2011 17:29

The error is definitely being thrown from Oracle.
jlentrichia
 
Posts: 12
Joined: Wed 11 May 2011 15:12

Postby 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.
Zero-G.
 
Posts: 390
Joined: Sat 09 Dec 2006 12:20

Postby 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.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48


Return to LinqConnect (LINQ to SQL support)