Oracle Sequences

Posts   
 
    
sfalzon
User
Posts: 7
Joined: 30-May-2007
# Posted on: 07-Jun-2007 17:33:16   

Hi

I have a table which has a PK comprised of 2 columns. One column is derived from a sequence, the other is a FK that is only unique in the context of the sequence number e.g

SQ number = 1 FK = A SQ number = 1 FK = B SQ number = 1 FK = C

SQ number = 2 FK = A SQ number = 2 FK = B SQ number = 2 FK = C

Is it possible to direct LLBLGen Pro 2.0 to generate ElementFieldMappings that assign sequence numbers for a range of rows rather than each row inserted.

Thanks for your time Steve

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 08-Jun-2007 09:34:11   

I have a table which has a PK comprised of 2 columns. One column is derived from a sequence, the other is a FK that is only unique in the context of the sequence number e.g

SQ number = 1 FK = A SQ number = 1 FK = B SQ number = 1 FK = C

SQ number = 2 FK = A SQ number = 2 FK = B SQ number = 2 FK = C

I don't understand how this sequence work? Say when you want to insert a new row with a specific FK from SQL Plus, how and where is the Sequence generated?

sfalzon
User
Posts: 7
Joined: 30-May-2007
# Posted on: 08-Jun-2007 11:33:46   

Walaa wrote:

I don't understand how this sequence work? Say when you want to insert a new row with a specific FK from SQL Plus, how and where is the Sequence generated?

Hi Walaa, thanks for getting back to me, please ignore the example above.

Ok, I have 2 Oracle sequences, GROUP_SQ and ITEM_SQ for example, generated in oracle using oracles built in sequence feature. Each number generated by GROUP_SQ will be assigned to a group of rows entered into a table, not to individual rows as they are inserted: it is not an identity just a numerical sequence.

ITEM_SQ is used as the identity for items in a related table and in LLBLGen I can assign it to the Is Identity/Sequence field on the Entities tab/Field Properties tab , which is what is required.

A number generated by GROUP_SQ is assigned to a range of rows as they are inserted rather than to a single row so I'm assuming (I don't know) that I can't assign it to the Identity/Sequence field and get the required functionality, is there a similar feature to assign a sequence number when a range of rows is inserted.

To be honest I think I've answered the question myself. I wouldn't expect that feature to be built in to llblgen but as I have little knowledge of your software I thought I'd ask. I'll figure out a way to achieve this whilst still using the objects generated by llblgen but if you have any ideas simple_smile

cheers

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39914
Joined: 17-Aug-2003
# Posted on: 08-Jun-2007 12:13:25   

You can't assign the group sequence to a field to get it auto-updated withthe proper value, as llblgen pro of course can't figure out what the group sizes are you semantically want to use simple_smile .

However, you can create simple stored proc which calls your group sequence's NEXTVAL method and returns that value. You then in llblgen pro assign a call to that procedure (action proc) and a method will be generated into the code. You then use that method to obtain the next group sq value which you assign to the groupid of your entities.

Frans Bouma | Lead developer LLBLGen Pro
sfalzon
User
Posts: 7
Joined: 30-May-2007
# Posted on: 08-Jun-2007 12:54:58   

Otis wrote:

You can't assign the group sequence to a field to get it auto-updated withthe proper value, as llblgen pro of course can't figure out what the group sizes are you semantically want to use simple_smile .

However, you can create simple stored proc which calls your group sequence's NEXTVAL method and returns that value. You then in llblgen pro assign a call to that procedure (action proc) and a method will be generated into the code. You then use that method to obtain the next group sq value which you assign to the groupid of your entities.

Thanks Otis wink