Hi,
You can create 3 sequences
1.SEQ_mgmt
2.SEQ_Netwrk
3.SEQ_otrs
like below syntax
<pre lang="sql">CREATE SEQUENCE sequence_name
[INCREMENT BY #]
[START WITH #]
[MAXVALUE # | NOMAXVALUE]
[MINVALUE # | NOMINVALUE]
[CYCLE | NOCYCLE]</pre>
in your procedure if the responsible person is management insert with SEQ_mgmt,
if its network insert with SEQ_ntwrk, if its others insert with SEQ_otrs.
insert accordingly
concatenate with M for management and N for network.
INSERT INTO members
(complaintcode)
VALUES ( 'M' || ltrim (to_char (customer_seq.NEXTVAL,0009));
See example to use sequences:
To create the sequence:
CREATE SEQUENCE customer_seq INCREMENT BY 1 START WITH 100
To use the sequence to enter a record into the database:
INSERT INTO customer (cust_num, name, address)
VALUES (customer_seq.NEXTVAL, 'John Doe', '123 Main St.')
To find the value just entered into the database:
SELECT customer_seq.CURVAL AS LAST_CUST_NUM
Hope this helps.