Ticket #16448: django_seq.pck

File django_seq.pck, 839 bytes (added by wiesiek@…, 13 years ago)
Line 
1CREATE OR REPLACE PACKAGE django_seq IS
2
3 FUNCTION NEXTVAL RETURN NUMBER;
4 FUNCTION CURRVAL RETURN NUMBER;
5END django_seq;
6/
7CREATE OR REPLACE PACKAGE BODY django_seq IS
8
9 last_val NUMBER;
10 shard_no NUMBER;
11
12 FUNCTION NEXTVAL RETURN NUMBER IS
13 BEGIN
14 SELECT to_number(to_char(mr_inne_seq.nextval) || lpad(shard_no, 4, '0')) ||
15 ltrim(to_char(MOD(abs(hsecs), 1000000), '000000'))
16 INTO last_val
17 FROM sys.v_$timer;
18 RETURN last_val;
19 END;
20
21 FUNCTION CURRVAL RETURN NUMBER IS
22 no_current_value EXCEPTION;
23 PRAGMA EXCEPTION_INIT(no_current_value, -8002);
24 BEGIN
25 IF (last_val IS NULL) THEN
26 RAISE no_current_value;
27 END IF;
28 RETURN last_val;
29 END CURRVAL;
30
31BEGIN
32 --- the code below can use database table lookup
33 shard_no := 5;
34
35END django_seq;
36/
Back to Top