Retrieving column values set by a trigger

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
kenkopp
Posts: 4
Joined: Mon 15 Sep 2008 19:20

Retrieving column values set by a trigger

Post by kenkopp » Mon 15 Sep 2008 19:27

Hello,

I am using OraDirect.NET with the Entity Framework. Many of our tables have identity columns, the values of which are set by triggers which use sequences. We need to be able to retrieve the values of these columns after calling SaveChanges().

In SQL Server, we would simply set the table's identity column, which would be automatically updated in the entity after calling SaveChanges(). However, Oracle doesn't have an equivalent.

If there was a way to get the sequences NEXTVAL and supply this to the table, that would be another way to approach the problem. However, it appears that the Entity Framework does not support sequences, so this approach is not an option.

Thanks in advance for any help!

huanghexd
Posts: 8
Joined: Tue 09 Sep 2008 19:06

Post by huanghexd » Mon 15 Sep 2008 21:04

If the column value is only set during insertion, you could add manually StoreGeneratedPattern="Identity" to the column defintion in the storage schema.

If the column value is set during insertion and update, you could add manually StoreGeneratedPattern="Computed" to the column defintion in the storage schema.

This works fine with me.

kenkopp
Posts: 4
Joined: Mon 15 Sep 2008 19:20

Post by kenkopp » Mon 15 Sep 2008 21:23

Hi huanghexd, thanks for taking the time to reply. I had found that tip in an earlier post and tried it before posting this, but it gives me the following compile-time error:

Error 5: The 'StoreGeneratedPattern' attribute is not allowed.

Any idea what might cause this?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 16 Sep 2008 07:11

The error "The 'StoreGeneratedPattern' attribute is not allowed" occurs if this attribute is set not in the Property tag at SSDL part.

Post Reply