Oracle, BusinessObjects & PrimaryKeyIsAutoIncremented on Update


Author
Message
Kari Paukku
Kari Paukku
StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)
Group: Forum Members
Posts: 65, Visits: 820
Hi,

noticed that when updating existing data the update fails
if the PrimaryKeyIsAutoIncremented is set to TRUE (=default (?)).

It's open to discussion if the default should be true or false, but in my opinion this shouldn't have effect when doing an update to data that already exists in the database....

Kari

StrataFrame Team
S
StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
What is the error that you're getting?  During an UPDATE operation, the primary key is always passed, no matter whether the PrimaryKeyIsAutoIncremented property is set to true or false.  Could you also tell me what CRUD settings you have (sprocs/no sprocs, concurrency type, etc.).
Kari Paukku
Kari Paukku
StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)
Group: Forum Members
Posts: 65, Visits: 820
Ben,

below is the error message. A comment to the error message that's in red: the primary key is type of VARCHAR2, not a NUMBER. This may be the reason for the error....

Kari

BusinessLayerException
 An error occurred while saving an the data to the server.
DataLayerSavingException
 Cannot create UPDATE command because PrimaryKeyIsAutoIncremented = True and the PrimaryKeyField is not a valid
auto-increment data type.
Exception
 Cannot create UPDATE command because PrimaryKeyIsAutoIncremented = True and the PrimaryKeyField is not a valid auto-increment data type.

Source     : MicroFour StrataFrame Business

Stack Trace:
   at MicroFour.StrataFrame.Data.DataLayer.BuildUpdateInfo(DataTable UpdatingTable, Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams)
   at MicroFour.StrataFrame.Data.DataLayer.SaveByForm(DataTable TableToSave, Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save(Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.OnFormClosing(FormClosingEventArgs e)
   at System.Windows.Forms.Form.WmClose(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

StrataFrame Team
S
StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Ah yes, if the primary key is not a numeric data type, then it cannot be auto-incremented by the server.  You will need to manually assign a primary key to the record since the data type cannot be auto-incremented.
Kari Paukku
Kari Paukku
StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)
Group: Forum Members
Posts: 65, Visits: 820
Hi,

yes, but when updating an existing record there is no need to increment anything....

"Cannot create UPDATE command because PrimaryKeyIsAutoIncremented = True and the PrimaryKeyField is not a valid auto-increment data type."

Kari

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
You should not get this message when an UPDATE is called.  The only time this matters is when INSERTing a new record.  If you do not want the BO to auto-retrieve the PK on INSERTs then simply set the PrimaryKeyIsAutoIncrementing property to False on the BO.
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)
Group: Forum Members
Posts: 153, Visits: 462
I am having a similar issue with Oracle. The actual Primary Key in the Oracle table has a type of "Numeric". The SF BO Mapper converted this to indicate a type of "Decimal". Unless is set the property on the BO for "PrimaryKeyIsAutoIncremented" to False, an error occurs when I go to SAVE a NEW record:

InvalidOperationException
  Collection was modified; enumeration operation may not execute.

Source     : mscorlib

Stack Trace:
   at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
   at System.Windows.Forms.Application.ExitInternal()
   at System.Windows.Forms.Application.Exit(CancelEventArgs e)
   at System.Windows.Forms.Application.Exit()
   at MicroFour.StrataFrame.Application.StrataFrameApplication.ShowThreadExceptionForm(Exception Ex)
   at MicroFour.StrataFrame.Application.StrataFrameApplication.HandleThreadException(Object sender, ThreadExceptionEventArgs e)
   at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t)
   at System.Windows.Forms.Control.WndProcException(Exception e)
   at System.Windows.Forms.Control.ControlNativewindow.OnThreadException(Exception e)
   at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at MicroFour.StrataFrame.Application.StrataFrameApplication.RunApplication()

The Update works, it is just when adding a new record in Oracle. This is not an issue with SQL. The problem with setting the BO property "PrimaryKeyIsAutoIncremented" to False is that although the SAVE works, I show the Primary Key column on the form which now does not get the key that was assigned. It shows blank until I requery the database. Are you aware of this Oracle issue, and is there a fix or workaround other than setting the "PrimaryKeyIsAutoIncremented" to False?

Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Could someone PLEASE answer my prior post. I cannot set the property yo false because I need to know the primary key that was assigned. This seems like a bug in SF. If so, is there a work around? If so, what code would I need to insert to insert to compensate.
StrataFrame Team
S
StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Looking at the stack trace, the error that you posted is not coming from the Oracle issues, it's coming from the application trying to close down when an the Oracle exception was thrown. 

Stack Trace:
   at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
   at System.Windows.Forms.Application.ExitInternal()
   at System.Windows.Forms.Application.Exit(CancelEventArgs e)
   at System.Windows.Forms.Application.Exit()
   at MicroFour.StrataFrame.Application.StrataFrameApplication.ShowThreadExceptionForm(Exception Ex)
   at MicroFour.StrataFrame.Application.StrataFrameApplication.HandleThreadException(Object sender, ThreadExceptionEventArgs e)

Notice how the exception comes from within the System.Windows.Forms.ExitInternal() method?  The HandleThreadException() method raises the UnhandledException static event on the StrataFrameApplication class.  This event should be handled automatically within the program.cs or AppMain.vb file.  So, there should be a red exception dialog popup and show the exception that fired right before this one.  If not, then something has changed within the handler of the UnhandledException event and is setting the e.Handled property to true on the event args. 

In order to diagnose the Oracle problem you're having, I'll need the Oracle exception that is being thrown, not this one that is being thrown when the application is trying to shutdown.  Thanks.

Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Here it is:

BusinessLayerException
  An error occurred while saving an the data to the server.
DataLayerSavingException
  ORA-00936: missing expression

OracleException
  ORA-00936: missing expression


Source     : MicroFour StrataFrame Business

Stack Trace:
   at System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc)
   at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals)
   at System.Data.OracleClient.OracleCommand.ExecuteScalarInternal(Boolean needCLStype, Boolean needRowid, OciRowidDescriptor& rowidDescriptor)
   at System.Data.OracleClient.OracleCommand.ExecuteScalar()
   at MicroFour.StrataFrame.Data.DbDataSourceItem.InternalExecuteScalar(DbCommand Command, Boolean IsTransactional, String TransactionKey)
   at MicroFour.StrataFrame.Data.OracleDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand)
   at MicroFour.StrataFrame.Data.DbDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler)
   at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams)
   at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTable(DataTable TableToUpdate, Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.Data.DataLayer.SaveByForm(DataTable TableToSave, Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save(Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save()
   at MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdSave_Click(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
   at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search