This is a migrated thread and some comments may be shown as answers.

DataStoreException

1 Answer 188 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Boris
Top achievements
Rank 1
Boris asked on 18 Nov 2008, 01:31 PM

Since I've updated to the new version of toa, I get the following DataStoreException...

I have the following code:

string oql = @"MAX(SELECT m_ActionDate FROM ActivityExtent AS a WHERE a.m_Contact != nil AND a.m_Contact.m_Id = $1 AND a.m_ActionDate >= $2)" 
 
object[] param = new object[2];  
param [0] = Guid.NewGuid();  
param [1] = SqlDateTime.MinValue.Value;  
 
IQuery query = this.ObjectScope.GetOqlQuery(oql);  
query.MaxResultCount = 1;  
 
    if (param != null)  
    {  
        using (IQueryResult result = query.Execute(param))  
        {  
            if (result.Count == 0) 


Whenever I'm on result.Count I get the following exception:

Telerik.OpenAccess.Exceptions.DataStoreException was unhandled
  Message="Error executing query: Telerik.OpenAccess.RT.sql.SQLException: Must declare the scalar variable \"@__TAKE\".\r\nStatement(s) could not be prepared.\r\n   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()\r\n   at OpenAccessRuntime.jdbc.conn.PooledPSWithParamLogging.executeQuery()\r\n   at OpenAccessRuntime.jdbc.fetch.FetchResultImp.execute()\nSQL:\nSELECT  TOP(??T) MAX(a.[ActionDate])                  FROM [tbl_Activity] a JOIN [tbl_Contact] AS b ON (a.[Contact_tbl_Contact_Id] = b.[Id]) WHERE a.[Contact_tbl_Contact_Id] is not null AND b.[Id] = ?         AND a.[ActionDate] >= ?  Telerik.OpenAccess.RT.sql.SQLException: Must declare the scalar variable \"@__TAKE\".\r\nStatement(s) could not be prepared.\r\n   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()\r\n   at OpenAccessRuntime.jdbc.conn.PooledPSWithParamLogging.executeQuery()\r\n   at OpenAccessRuntime.jdbc.fetch.FetchResultImp.execute()"
  Source="Telerik.OpenAccess"
  CanRetry=false
  StackTrace:
       at Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
       at Telerik.OpenAccess.RT.ExceptionWrapper.Throw()
       at OpenAccessRuntime.storagemanager.logging.LoggingStorageManager.executeQueryAll(ApplicationContext context, ImmutableQueryDetails query, CompiledQuery compiledQuery, Object[] para, Int32 skip, Int32 take)
       at OpenAccessRuntime.jdo.SynchronizedPMProxy.getAllQueryResults(CompiledQuery cq, Object[] para, Int32 skip, Int32 take)
       at OpenAccessRuntime.jdo.VersantQueryImp.executeWithArrayImp(Object[] parameters)
       at OpenAccessRuntime.jdo.VersantQueryImp.executeWithArray(Object[] parameters)
       at Telerik.OpenAccess.RT.QueryResultImpl.check()
       at Telerik.OpenAccess.RT.ListEnumerator.get_Count()
  InnerException: Telerik.OpenAccess.RT.sql.SQLException
       Message="Must declare the scalar variable \"@__TAKE\".\r\nStatement(s) could not be prepared."
       Source="Telerik.OpenAccess.Adonet2"
       Description="SQLState=;Must declare the scalar variable \"@__TAKE\".\r\nStatement(s) could not be prepared."
       ErrorCode=137
       Number=137
       StackTrace:
            at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()
            at OpenAccessRuntime.jdbc.conn.PooledPSWithParamLogging.executeQuery()
            at OpenAccessRuntime.jdbc.fetch.FetchResultImp.execute()
       InnerException: 
        {"Must declare the scalar variable \"@__TAKE\".\r\nStatement(s) could not be prepared."}

thx for your help
Boris

 

1 Answer, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 18 Nov 2008, 02:12 PM
Hello Boris,

that is a bug which is already fixed and the next version will contain the fix. However, in this scenario the MaxResultCount setting is really redundant as the MAX alone will ensure that not more than one element can be returned, so you might want to take that out as a workaround.
The next patch is scheduled for end of next week.

All the best,
Thomas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Boris
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Share this question
or