Generate primary key from database function

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
JEH
Posts: 5
Joined: Mon 06 Jun 2011 09:00

Generate primary key from database function

Post by JEH » Mon 06 Jun 2011 09:06

I'm trying to get the primary key generated from an oracle database function like described in the release notes for dotConnect for Oracle 6.30.

I have created a function like this:

create or replace function f_get_sequence return number
as
ll_seq number;
begin
select ocs_sequence.nextval into ll_seq from dual;
return ll_seq;
end;

On the table in the entity model I've set storegenerated pattern to identity and default value to f_get_sequence() on the primary key column.

But, it isn't working. Any thoughts on what I'm doing wrong?


Regards,
Jan Erik

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Mon 06 Jun 2011 12:57

The Default value specified in Visual Studio should be a constant and have the type corresponding to the property type, in the other case it will be ignored.
We are working on the devart:DefaultValue attribute for Devart Entity models.
I will let you know as soon as this feature is implemented.

JEH
Posts: 5
Joined: Mon 06 Jun 2011 09:00

Post by JEH » Tue 07 Jun 2011 06:50

In the release notes for 6.30 you write the following:

"To facilitate the process of development and to cease using simple INSERT triggers that set values of Identity columns, we make it possible to use database-specific functions as Default Value when inserting records into tables."

How do I accomplish this?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 07 Jun 2011 08:38

Sorry for the inconvenience. The current release contains a problem with the Default Value implementation for the Identity columns.
In the upcoming build the default value (no matter DefaultValue or devart:DefaultValue) will be inserted into DB if the InsertNullBehaviour is set either to InsertDefaultOrNull or to InsertDefaultOrOmit.
The upcoming build will be available in two weeks or so. I will notify you as soon as it is available.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 10 Jun 2011 12:05

The problem with Default value and Identity columns is fixed in the upcoming build.
This build will be available in a week or so.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 16 Jun 2011 10:58

This problem is fixed in the latest 6.30.172 build of dotConnect for Oracle. The new build can be dowloaded from here (the trial version) or from Registered Users' Area (for users with active subscription only):
For the detailed information about the improvements and fixes available in dotConnect for Oracle 6.30.172, please refer to
this announcement.

Post Reply