Getting PK sequence Value from Oracle

Posts   
 
    
grjoseph
User
Posts: 7
Joined: 03-Mar-2010
# Posted on: 03-Mar-2010 21:23:48   

Hi All,

I am using LLBLGen to write data to a table in Oracle. this table has a column (BILLINGID) that is a primary key and Auto-Increments the Value of that column...

ie.. row 1 = 1, row 2 = 2 etc....

the problem I am having is that when I use LLBLGen to do a insert, I always get this error.

The given key was not present in the dictionary (from the Insertentity code in the LLBLGen generated code)

If I set the BILLINGID myself to a number then it will insert fine. there is a trigger set up for this Column to auto increment and I put this into the .conf file.

"<add key="OracleTriggerSequences" value="true" />"

does anyway have any advice on how I can fix this...it looks like I have to retrieve the next sequence value but I am not sure how to do that.

thanks in advance.

Gerard

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-Mar-2010 04:04:36   

Did you flag the field as Identity in LLBLGen Designer?

David Elizondo | LLBLGen Support Team
grjoseph
User
Posts: 7
Joined: 03-Mar-2010
# Posted on: 04-Mar-2010 04:33:27   

hey,

thanks for getting back to me. actually no, I forgot to set that but after I went and set it I get a new error now....I get this error thrown

An exception was caught during the execution of an action Query. cannot insert NULL into ("NNH_USER"."BILLING"."BILLINGID"). etc..

this is where I set my fields. I do not set BILLINGID as it is supposed to auto increment etc. BillSubMgr is a child table of Billing. this same code works fine when used agains SQL 2005...

        BillingSubMgr.Recordid = Record.ID.ToString
        BillingSubMgr.Clientid = BLL.GetClientIDByIdentifier(Record.Client)
        BillingSubMgr.Serverid = BLL.GetServerIDByIdentifier(Record.Server)
        BillingSubMgr.Entrydate = Record.RecordTime
        BillingSubMgr.Type = Payload.GetType.Name.ToString
        BillingSubMgr.Istest = "N"
        BillingSubMgr.Count = Payload.Count

        BillingSubMgr.Save()
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-Mar-2010 04:39:01   

So, you have the Identity on Designer and the OracleTriggerSequences flat to true on config file, right?

LLBLGen runtime library version? (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7725)

David Elizondo | LLBLGen Support Team
grjoseph
User
Posts: 7
Joined: 03-Mar-2010
# Posted on: 04-Mar-2010 04:47:20   

hey.

yes I have the config file set up with this

<appSettings> <add key="OracleTriggerSequences" value="true" /> </appSettings>

I am using LLBLGen 2.6 and connecting to an Oracle 10g db. I am not a Oracle expert by any means as this is the first time I have to connect to one, I had someone else how knows Oracle create the triggers. I do not have much more info on this DB at the moment.

this application is a .net 3.5 app.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 04-Mar-2010 10:28:35   

You should also specify the Sequence Used for the field in the Designer.

grjoseph
User
Posts: 7
Joined: 03-Mar-2010
# Posted on: 04-Mar-2010 15:29:17   

hello,

I provided a screen shot in my previous post with all the fields i set up in the designer. I selected the BILLING_SEQ option. I am guess that it what I was supposed to select?

I have attached another screen shot of the error that I am getting. I am getting frustrated as to what the problem is.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 04-Mar-2010 17:07:20   

The sequences available in llblgen pro are the ones which are found in the schema(s) you read for the project. This means: they're visible (either directly or through synonyms) to the user you used to connect to the schema when you refreshed or created the project.

At runtime, this means that the sequence assigned to a field is used in a query to produce a sequence retrieval query. This also means that if you run the generated code (thus your application) under a different user, it could be that that user can't see that sequence as it for example has no access rights to a synonym or the schema to begin with. Please check the error Oracle reported and the oracle documentation on that error. Please verify that the user connecting to oracle can see the sequence you assigned. If in doubt, please ask your DBA if you have a DBA managing the oracle database.

A tip which will help you: please enable tracing. Then run your application in debug mode so you should see the SQL generated being logged to the vs.net output window. This will help you identify the problem because you can then see which queries are being generated and for example which sequence retrieval query is generated using which sequence.

Frans Bouma | Lead developer LLBLGen Pro
grjoseph
User
Posts: 7
Joined: 03-Mar-2010
# Posted on: 04-Mar-2010 18:09:25   

thanks for all your help guys. I finally got things working, once I got the tracing working it was able to see all the queries.

this was the one that was causing problems

Sequence query: SELECT "NNH_USER"."BILLING_SEQ".CURRVAL FROM DUAL
Executes before INSERT: False

once we moved that to execute before the insert all is working now..

thanks again.