0

how can i do something like this:

I have two tables, A and B. A --> B is one to many.

B has a varchar field that we will call field1.

I have also a sequence seq1 that i want to use in this way:

Suppose we have A1 and A2, two records belonging to table A. A1 has (B1,B2,B3,B4) and A2 has (B5,B6).

I want to use the sequence for each group and start from the beginning each time i change group to update field1 in B. So i will have somthing like

B1.field1 = 1, B2.field1 = 2, B3.field1 = 3, B4.field1 = 4

now the sequence start back from 1 for A2:

B5.field1 = 1, B6.field2 = 2.

Is there some complex nested structure to do that or i need a function?

I was thinking about using a temporary table ,playing a bit on indexes and sub countings but i don't manage to find a wayout.

Thanks

tadman
  • 208,517
  • 23
  • 234
  • 262

0 Answers0