Oracle, BusinessObjects & PrimaryKeyIsAutoIncremented on Update


Author
Message
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)
Group: Forum Members
Posts: 153, Visits: 462
For me it seems inserting the following code in the BO "AfterSave" event worked:

this.tbl_BargeClass_1.FillDataTable("Select * from TBL_BARGECLASS_1 WHERE BARGECLASS_PKCODEID = ( SELECT MAX(BARGECLASS_PKCODEID) FROM TBL_BARGECLASS_1 )");

this.tbl_BargeClass_1.Navigate(MicroFour.StrataFrame.Business.BusinessNavigationDirection.Last);

I would still like to know if there is a bug in the SF framework or if there may be a better approach.

 


Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Here is some information that may help:

The Auto Incrementing Primary Key in SQL called BAREGECLASS_PKCODEID, which works, is INT and in the SF Mapper is set to not allow Null values and no default value is set. This work for SQL perfectly.

In Oracle the Primary Key called BAREGECLASS_PKCODEID, does not have an INT type but is a type of "Numeric". The SF Business Mapper converts the Numeric to a type of "Decimal" for the BO that it generates. Since there is no such setting as auto increment of a column in an Oracle table, there is an event (TBL_BARGECLASS_1_BARGECLASS__1 sequence) in the Oracle table that increments the Primary Key when a new row is added.

The setting in the Mapper for the BAREGECLASS_PKCODEID is to not allow null values and nothing defaults on a new row. The never works regardless of the setting of PrimaryKeyIsAutoIncremented property on the BO.

If I set the property to True, when I click SAVE the error in my earlier Post occurs. If I set the value to False, then another error occurs as a result on the Primary Key being a NULL value.

To make it work without an error, I need to set the PrimaryKeyIsAutoIncremented property on the BO to "False", and then on the BO, set the Primary Key config to RETURN ALTERNATE VALUE ON NULL, and specify a value of "0". Then when I added a new row to the table no error occurs, and in the backend Oracle table the Primary Key seems to be updated, but on the screen after the update is complete, the textbox showing the Primary Key shows the default of "0". The only way to compensate with these settings seems to be to include some code in an "AfterSave" event of the BO if running Oracle to refresh the BO from the database. If this is what is needed, would you let me know what code would be needed.

Also you may want to fix this behavior. It seems like it is a bug in SF.

Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 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)

StrataFrame Team
S
StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K 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 (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 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.
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 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?

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.
Kari Paukku
Kari Paukku
StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 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

StrataFrame Team
S
StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K 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 (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 reputation)StrataFrame Novice (73 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)

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