Page 1 of 1

ORA-01036 while updating in Enity Framework

Posted: Fri 18 Mar 2011 18:32
by mitch.etter
I'm attempting to update a self-tracking entity in entity framework 4 using the dotConnect v6.10.121, and I'm getting this exception: "ORA-01036 illegal variable name/number".

Code: Select all

using (var transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))
using (var context = new Entities())
{
	var fetchedEntity = context.TestEntities.Single(e => e.Id == newEntity.Id);
	fetchedEntity.StartTracking();
	fetchedEntity.Name = "updated name";
	context.TestEntities.ApplyChanges(fetchedEntity);
	context.SaveChanges();
	transaction.Complete();
	fetchedEntity.AcceptChanges();
}
System.Data.UpdateException was caught
Message=An error occurred while updating the entries. See the inner exception for details.
Source=System.Data.Entity
StackTrace:
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at System.Data.Objects.ObjectContext.SaveChanges()
at DevartOracleEntityComputedProperty.Program.Main(String[] args) in c:\users\metter\documents\visual studio 2010\Projects\DevartOracleEntityComputedProperty\DevartOracleEntityComputedProperty\Program.cs:line 39
InnerException: Devart.Data.Oracle.OracleException
Message=ORA-01036 illegal variable name/number
Source=Devart.Data.Oracle
ErrorCode=-2147467259
Code=1036
Offset=0
StackTrace:
at Devart.Data.Oracle.w.a(a3[] A_0, Byte[] A_1, Hashtable A_2)
at Devart.Data.Oracle.OracleCommand.InternalExecute(CommandBehavior behavior, IDisposable disposable, Int32 startRecord, Int32 maxRecords, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at Devart.Data.Oracle.Entity.e.a(CommandBehavior A_0)
at Devart.Common.Entity.bb.b(CommandBehavior A_0)
at Devart.Data.Oracle.Entity.e.b(CommandBehavior A_0)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
InnerException:
The entity's LastModified property has StoreGeneratedPattern="Computed" and ConcurrencyMode="Fixed". The value of LastModified is changed in the database with a trigger to implement optimistic concurrency. The Id property has StoreGeneratedPattern="Identity" that is also updated with a trigger.

Code: Select all


  
  
    
    
      
        
          
        
        
          
            
          
          
          
          
        
      
    
    
    
      
        
          
        
        
          
            
          
          
          
          
        
      
    
    
    
      
        
          
            
            
            
          
        
      
    
  
  
  
    
      
        
      
    
    
      
        
        
        
        
      
    
    
    
      
        
      
    
  

Code: Select all

CREATE SEQUENCE TEST_ENTITY_SEQ MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1;
/

CREATE TABLE TEST_ENTITY
(
	ID NUMBER(16, 0) NOT NULL,
	NAME VARCHAR2(255),
	LAST_MODIFIED TIMESTAMP(6),
	CONSTRAINT TEST_ENTITY_PK PRIMARY KEY (ID)
);
/

CREATE OR REPLACE TRIGGER TEST_ENTITY_INSERT
	BEFORE INSERT ON TEST_ENTITY FOR EACH ROW
	BEGIN
		SELECT TEST_ENTITY_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
	END;
/

CREATE OR REPLACE TRIGGER TEST_ENTITY_UPDATE
	BEFORE INSERT OR UPDATE ON TEST_ENTITY FOR EACH ROW
	BEGIN
		:NEW.LAST_MODIFIED := SYSTIMESTAMP;
	END;
/
When I use dbMonitor to look at the generated update SQL being sent to the database, I see this statement that appears to be missing a space after the :p2 parameter.
DECLARE
updatedRowid ROWID;
BEGIN
UPDATE STRM.TEST_ENTITY
SET NAME = :p0
WHERE ID = :p1 AND LAST_MODIFIED = :p2RETURNING ROWID INTO updatedRowid;
OPEN :outParameter FOR SELECT LAST_MODIFIED FROM STRM.TEST_ENTITY WHERE ROWID = updatedRowid;
END;
When I uninstalled dotConnect v6.10.121 and installed v6.10.111, I did not receive an exception. Should I be doing something different switching from 6.10.111 and 6.10.121?

I'm using Windows 7 Professional x64 SP1, Visual Studio 2010 Premium SP1, Oracle 11g (11.20.1.0) 64-bit and .NET 4.

Posted: Mon 21 Mar 2011 09:26
by AndreyR
Thank you for the report, this error was already found and fixed.
The fix will be available in the nearest build.

Posted: Thu 07 Apr 2011 13:06
by AndreyR
The new build of dotConnect for Oracle 6.10.135 is available for download now. This build fixes the ORA_ROWSCN problem.
It can be downloaded from Download Page (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to this post.