Trouble with FK management in an Oracle environment


Author
Message
Kirk M Sherhart
Kirk M Sherhart
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 41, Visits: 259
Hi Trent



Glad to help!



I also noticed that the pre/post primary key values are filled by accessing a DataRow, but the _DataLayer_AfterSave event looks at BusinessLayer objects. In my case with Oracle, I typically customize ID fields to return integers from the native decimal values. Therefore, the pre/post primary key values are stored as native decimal types (because that's what the datarow sees) . But, the fkValue coming through the BO is converted to an integer.



So, either get the pre/post primary key values from the datarow, and use datarows in _DataLayer_AfterSave or (vice versa) use values from the BusinessLayer.
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
Good find. I think that you may be on to something here. This should most likely have a test on types as the value does need to be determined (must be less than zero). I will look at this in the morning and see if I can come up with a test for you to try. Thanks.



Kirk M Sherhart
Kirk M Sherhart
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 41, Visits: 259
Hi Trent



The problem is in the _DataLayer_AfterSave event as follows:





For Each record As BusinessLayer In info.BusinessObject.GetEnumerable()

'-- If the fkField is < 0, it needs to be replaced

fkValue = CType(record(info.ForeignKeyField), Long)w00t

If fkValue < 0 Then

record(info.ForeignKeyField) = Me.GetPostSavePrimaryKeyValue(fkValue)

End If

Next





The fkValue of type long will not find a pre-save key value of type decimal.



Most likely the code should read something like as follows:





record(info.ForeignKeyField) = Me.GetPostSavePrimaryKeyValue(record(info.ForeignKeyField))





Hope this helps.
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
Sorry for the delay on this post Blush I missed it.



Actually the type of the columns going into and out of the save collection as the same type. If you'll notice, the GetPostSavePrimaryKeyValue actually returns an object. There is no casting that takes place within the collection. Also, this should have nothing to do with the database. The logic here is not database dependent.



If you have not made any progress on this then I will need to get more details from you such as the database version, structure, and a small sample. There is something else in the mix here unrelated to the core workings of the framework.
Kirk M Sherhart
Kirk M Sherhart
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 41, Visits: 259
I'm having trouble getting FK management working in an Oracle environment.



I notice that pre/post primary key value pairs are stored in the _PrimaryKeyPostPreSaveValues dictionary as decimals (which Oracle uses for all numeric values.) However, during the _DataLayer_AfterSave event, the procedure GetPostSavePrimaryKeyValue uses a Long value to look for the old PK value. Therefore, the old primary key value is not found, returning a null value.



Am I missing something?



Thanks!
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