Create Sequence xxseq
Sequence created.
Create Table xxa (a Number)
Table created.
Create Table xxb (a Number)
Table created.
Insert All
When rn = 1 Then Into xxa(a) Values (xxseq.nextval)
When 1=1 Then Into xxb(a) Values (xxseq.currval)
Select Level rn From Dual Connect By Level <= 5
6 row(s) inserted.
Select a From xxa
A | 1 |
---|
Select a From xxb
A | 1 | 2 | 3 | 4 | 5 |
---|
Create Function xxgetseq(p_method In Varchar2) Return Number
Is
Begin
If p_method = 'NEXTVAL' Then
Return xxseq.nextval;
Elsif p_method = 'CURRVAL' Then
Return xxseq.currval;
End If;
End;
Function created.
Delete xxa
1 row(s) deleted.
Delete xxb
5 row(s) deleted.
Drop Sequence xxseq
Sequence dropped.
Create Sequence xxseq
Sequence created.
Insert All
When rn = 1 Then Into xxa(a) Values (xxgetseq(p_method=>'NEXTVAL'))
When 1=1 Then Into xxb(a) Values (xxgetseq(p_method=>'CURRVAL'))
Select Level rn From Dual Connect By Level <= 5
6 row(s) inserted.
Select a From xxa
A | 1 |
---|
Select a From xxb
A | 1 | 1 | 1 | 1 | 1 |
---|