Sql error - bad field name

Posts   
 
    
tahoepete
User
Posts: 13
Joined: 30-Mar-2007
# Posted on: 10-Aug-2007 21:02:00   

I’m get an interesting exception on a GetMulti()(Notice the ‘&’ instead of an ‘F’ in ‘&ILEPATH’)…

{"An exception was caught during the execution of a retrieval query: Dynamic SQL Error\nSQL error code = -206\nColumn unknown\nLOCALAUDIOTRACK.&ILEPATH\nNo message for error code 336397208 found.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception."}

"\r\n\tQuery: SELECT LOCALAUDIOTRACK.PUID AS Puid, LOCALAUDIOTRACK.MUSICGIANTSAUDIOTRACKID AS Musicgiantsaudiotrackid, LOCALAUDIOTRACK.MUSICGIANTSALBUMID AS Musicgiantsalbumid, LOCALAUDIOTRACK.OTHERID AS Otherid, LOCALAUDIOTRACK.FILEPATH AS Filepath, LOCALAUDIOTRACK.CODECID AS Codecid, LOCALAUDIOTRACK.BITRATE AS Bitrate, LOCALAUDIOTRACK.STATE AS State, LOCALAUDIOTRACK.CUSTOMID AS Customid FROM LOCALAUDIOTRACK WHERE ( ( LOCALAUDIOTRACK.FILEPATH = @Filepath1))\r\n\tParameter: @Filepath1 : String. Length: 512. Precision: 0. Scale: 0. Direction: Input. Value: d:\Documents and Settings\pgissel\My Documents\My Music\Alasdair Fraser\Road North\Calliope House_The Cowboy Jig.wma.\r\n"

I’m using version LLBL 1.0.2005.1 with the Firebird .Net provider 1.7.1 in Visual Studio 2005 C#.

Posts: 254
Joined: 16-Nov-2006
# Posted on: 12-Aug-2007 00:58:05   

Can you please post a full call stack when this exception is raised

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 13-Aug-2007 09:54:49   

Also please post the runtime library version in use. ref: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7725

tahoepete
User
Posts: 13
Joined: 30-Mar-2007
# Posted on: 13-Aug-2007 21:45:40   

Sorry, Runtime version 1.0.20051.60719.

Stack Trace:

at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityCollection collectionToFill, Boolean allowDuplicates, IValidator validatorToUse, IEntityFields fieldsUsedForQuery)

at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAction(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IValidator validatorToUse, IPredicate selectFilter, IRelationCollection relations, Int32 pageNumber, Int32 pageSize)

at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetMulti(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IValidator validatorToUse, IPredicate selectFilter, IRelationCollection relations, Int32 pageNumber, Int32 pageSize)

at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase.GetMulti(IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, Int32 pageNumber, Int32 pageSize)

at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase.GetMulti(IPredicate selectFilter)

at Serrano.LocalLibrary.LocalAudioTrack.GetLocalAudioTrack(String filepath) in D:\\VSProjects\\Projects\\SDK\\Serrano\\LocalLibrary\\LocalAudioTracks\\LocalAudioTrack.cs:line 155\r\n at Serrano.LocalLibrary.LocalLibraryManager.AddFilesToDb(Int32& count, Int32 totalFiles, Int32 runningTotal) in D:\\VSProjects\\Projects\\SDK\\Serrano\\LocalLibrary\\LocalLibraryManager.cs:line 465

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 14-Aug-2007 05:30:03   

Seems a DQE bug fixed in 2.x version: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=9255

We are looking for a fixed/workaround for 1.2005.x for you.

David Elizondo | LLBLGen Support Team
tahoepete
User
Posts: 13
Joined: 30-Mar-2007
# Posted on: 14-Aug-2007 20:34:33   

Looks like I'll be upgrading, overdue anyway.

Thanks for your help!

tahoepete
User
Posts: 13
Joined: 30-Mar-2007
# Posted on: 15-Aug-2007 20:09:03   

Ok, I upgraded to 2.0 and now I get the following exception. Am I missing something that I need to be doing different with 2.0? I looked over the what's new section and nothing jumped out at me.

{"An exception was caught during the execution of a retrieval query: invalid request handle. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception."}

"\r\n\tQuery: SELECT \"LOCALAUDIOTRACK\".\"PUID\" AS \"Puid\", \"LOCALAUDIOTRACK\".\"MUSICGIANTSAUDIOTRACKID\" AS \"Musicgiantsaudiotrackid\", \"LOCALAUDIOTRACK\".\"MUSICGIANTSALBUMID\" AS \"Musicgiantsalbumid\", \"LOCALAUDIOTRACK\".\"OTHERID\" AS \"Otherid\", \"LOCALAUDIOTRACK\".\"FILEPATH\" AS \"Filepath\", \"LOCALAUDIOTRACK\".\"CODECID\" AS \"Codecid\", \"LOCALAUDIOTRACK\".\"BITRATE\" AS \"Bitrate\", \"LOCALAUDIOTRACK\".\"STATE\" AS \"State\", \"LOCALAUDIOTRACK\".\"CUSTOMID\" AS \"Customid\", \"LOCALAUDIOTRACK\".\"ARTISTID\" AS \"Artistid\", \"LOCALAUDIOTRACK\".\"LOSSLESS\" AS \"Lossless\", \"LOCALAUDIOTRACK\".\"MUSICGIANTSARTISTID\" AS \"Musicgiantsartistid\" FROM \"LOCALAUDIOTRACK\" WHERE ( \"LOCALAUDIOTRACK\".\"FILEPATH\" = @Filepath1)\r\n\tParameter: @Filepath1 : String. Length: 512. Precision: 0. Scale: 0. Direction: Input. Value: \"d:\Documents and Settings\pgissel\My Documents\My Music\3 Doors Down\Seventeen Days\06 The Real Life.wma\".\r\n"

Version 2.0.0.0, build 06112007.

Stack Trace

at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteSingleRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityFields fieldsToFill) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformFetchEntityAction(IEntity entityToFetch, ITransaction containingTransaction, IPredicateExpression selectFilter, IPrefetchPath prefetchPathToUse, Context contextToUse) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.FetchExisting(IEntity entityToFetch, ITransaction containingTransaction, IPrefetchPath prefetchPathToUse, Context contextToUse) at MGN.V2.DAL.MgClient.EntityClasses.LocalaudiotrackEntity.Fetch(String filepath, IPrefetchPath prefetchPathToUse, Context contextToUse) in D:\\VSProjects\\Projects\\Common\\MGN.V2.DAL.MgClient\\EntityClasses\\LocalaudiotrackEntity.cs:line 825 at MGN.V2.DAL.MgClient.EntityClasses.LocalaudiotrackEntity.Refetch() in D:\\VSProjects\\Projects\\Common\\MGN.V2.DAL.MgClient\\EntityClasses\\LocalaudiotrackEntity.cs:line 368 at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.CheckForRefetch() at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.GetCurrentFieldValue(Int32 fieldIndex) at MGN.V2.DAL.MgClient.EntityClasses.LocalaudiotrackEntity.get_Filepath() in D:\\VSProjects\\Projects\\Common\\MGN.V2.DAL.MgClient\\EntityClasses\\LocalaudiotrackEntity.cs:line 998 at Serrano.LocalLibrary.LocalAudioTrack.get_FilePath() in D:\\VSProjects\\Projects\\SDK\\Serrano\\LocalLibrary\\LocalAudioTracks\\LocalAudioTrack.cs:line 86 at Serrano.LocalLibrary.LocalLibraryManager.IdentifyFile(LocalAudioTrack track) in D:\\VSProjects\\Projects\\SDK\\Serrano\\LocalLibrary\\LocalLibraryManager.cs:line 335

tahoepete
User
Posts: 13
Joined: 30-Mar-2007
# Posted on: 15-Aug-2007 23:18:34   

Ok, that previous method happens when I am reading the record from one thread while writing to the record from another thread. I can get past that one at least temporarily. But now I am getting this latest problem, which happens similarly to the original one.

Version 2.0.0.0 Runtime build 06112007

Exception: {"An exception was caught during the execution of a retrieval query: Dynamic SQL Error\r\nSQL error code = -104\r\nToken unknown - line 1, char 616\r\n(. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception."}

QueryExecuted: "\r\n\tQuery: SELECT \"LOCALAUDIOTRACK\".\"PUID\" AS \"Puid\", \"LOCALAUDIOTRACK\".\"MUSICGIANTSAUDIOTRACKID\" AS \"Musicgiantsaudiotrackid\", \"LOCALAUDIOTRACK\".\"MUSICGIANTSALBUMID\" AS \"Musicgiantsalbumid\", \"LOCALAUDIOTRACK\".\"OTHERID\" AS \"Otherid\", \"LOCALAUDIOTRACK\".\"FILEPATH\" AS \"Filepath\", \"LOCALAUDIOTRACK\".\"CODECID\" AS \"Codecid\", \"LOCALAUDIOTRACK\".\"BITRATE\" AS \"Bitrate\", \"LOCALAUDIOTRACK\".\"STATE\" AS \"State\", \"LOCALAUDIOTRACK\".\"CUSTOMID\" AS \"Customid\", \"LOCALAUDIOTRACK\".\"ARTISTID\" AS \"Artistid\", \"LOCALAUDIOTRACK\".\"LOSSLESS\" AS \"Lossless\", \"LOCALAUDIOTRACK\".\"MUSICGIANTSARTISTID\" AS \"Musicgiantsartistid\" FROM \"LOCALAUDIOTRACK\" WHERE ( ( \"LOCALAUDIOTRACK\".\"FILEPATH\" = @Filepath1))\r\n\tParameter: @Filepath1 : String. Length: 512. Precision: 0. Scale: 0. Direction: Input. Value: \"d:\Documents and Settings\pgissel\My Documents\My Music\NINE INCH NAILS\Year Zero\Nine Inch Nails-Year Zero-05-Vessel.wma\".\r\n"

StackTrack: " at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityCollection collectionToFill, Boolean allowDuplicates, IEntityFields fieldsUsedForQuery)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAction(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, Int32 pageNumber, Int32 pageSize)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetMulti(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IPredicate selectFilter, IRelationCollection relations, Int32 pageNumber, Int32 pageSize)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase1.GetMulti(IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, Int32 pageNumber, Int32 pageSize)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase1.GetMulti(IPredicate selectFilter)\r\n at Serrano.LocalLibrary.LocalAudioTrack.GetLocalAudioTrack(String filepath) in D:\\VSProjects\\Projects\\SDK\\Serrano\\LocalLibrary\\LocalAudioTracks\\LocalAudioTrack.cs:line 161\r\n at Serrano.LocalLibrary.LocalLibraryManager.AddFilesToDb(Int32& count, Int32 totalFiles, Int32 runningTotal) in D:\\VSProjects\\Projects\\SDK\\Serrano\\LocalLibrary\\LocalLibraryManager.cs:line 666\r\n at Serrano.LocalLibrary.LocalLibraryManager.FindFilesBase(Object obj) in D:\\VSProjects\\Projects\\SDK\\Serrano\\LocalLibrary\\LocalLibraryManager.cs:line 613\r\n at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Threading.ThreadHelper.ThreadStart(Object obj)"

tahoepete
User
Posts: 13
Joined: 30-Mar-2007
# Posted on: 16-Aug-2007 02:47:37   

This appears to be related to multi-threading, when I have more than one thread simultaneously accessing the same table. Are there any multi-threading issues/precautions that I should be aware of?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 16-Aug-2007 11:06:20   

I'm not sure this is caused by the multi-threading.

What happens if you copy the generated SQL query and run it manually against the database?

Can this behaviour be re-produced using simple ADO.NET without LLBLGen Pro?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 16-Aug-2007 18:47:35   

Do not share entities among threads. Do you share entities or other objects among the threads?

Frans Bouma | Lead developer LLBLGen Pro
tahoepete
User
Posts: 13
Joined: 30-Mar-2007
# Posted on: 17-Aug-2007 02:19:40   

It definitely seems to be multi-threaded related, which makes sense after thinking about it. I put locking mechanisms in place around the enitities in appropriate places and the problem seems to have gone away.

I am now trying to get a row count on a table. Firebird does not support the GetDbCount() method so I am trying to use the GetScalar() method. What would I use for the Expression parameter? I tried null, but then I get zero back.

Thanks for the help guys!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 17-Aug-2007 10:00:18   

What would I use for the Expression parameter? I tried null, but then I get zero back.

Did you use AggrgateFunction.CountRow? Would you please post the GetScalar code?

tahoepete
User
Posts: 13
Joined: 30-Mar-2007
# Posted on: 17-Aug-2007 19:22:36   

Here is the GetScalar code. If I do a GetMulit, it returns rows, so I'm assuming it is the expression argument this is making the GetScalar not work, although I don't need an expression , I just want a row count.

        LocalaudiotrackCollection tracks = new LocalaudiotrackCollection();
        PredicateExpression filter = new PredicateExpression(LocalaudiotrackFields.Puid == DBNull.Value);
        int totalTracks = (int)tracks.GetScalar(LocalaudiotrackFieldIndex.Puid, null, AggregateFunction.Count, filter);
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Aug-2007 06:14:02   

If I do a GetMulit, it returns rows

You mean, if you perform a GetMulti(filter) you obtain entities?

Could you please post the SQL Generated for that GetScarlar (See LLBLGenPro Help - Using generated code - Troubleshooting and debugging)?

David Elizondo | LLBLGen Support Team
tahoepete
User
Posts: 13
Joined: 30-Mar-2007
# Posted on: 20-Aug-2007 19:00:08   

Here is the SQL generated:

SELECT FIRST 1 COUNT("LOCALAUDIOTRACK"."PUID") AS "Puid" FROM "LOCALAUDIOTRACK" WHERE ( "LOCALAUDIOTRACK"."PUID" IS NULL)

I tried running this query directly and it returns 0. If I change it to

SELECT COUNT(*) FROM "LOCALAUDIOTRACK" WHERE ( "LOCALAUDIOTRACK"."PUID" IS NULL)

it returns the correct number.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Aug-2007 03:48:27   

Aaahhh, yes. That is because:

SQLServer wrote:

COUNT(ALL expression) evaluates expression for each row in a group and returns the number of **nonnull **values.

Instead, you should use:

SQLServer wrote:

COUNT(*) returns the number of items in a group. This includes NULL values and duplicates.

You should use AggregateFunction.CountRow instead of AggregateFunction.Count.

Regards.

David Elizondo | LLBLGen Support Team