Is the procedure correct for generating Sequence number in oracle -
please check if following procedure correct? insertion not happening.
i want generate sequence number in first column. please let me know if correct.
create or replace procedure sp_jcp_set_det_bnd_lst( p_channel in varchar2, p_deptbrandlistname in varchar2, p_groupno in number, p_userid in varchar2 ) sequenceid number; begin select seqid1+1 sequenceid from(select channel_dept_brand_list_id seqid1 gmppfc.channel_dept_brand_list order channel_dept_brand_list_id desc) rownum=1; insert gmppfc.channel_dept_brand_list ( channel_dept_brand_list_id, channel_nm, dept_brand_list_nm, group_no, create_user_id, create_ts, change_user_id, change_ts) values ( sequenceid, p_channel, p_deptbrandlistname, p_groupno, p_userid, sysdate, null, null ); commit; null; end sp_jcp_set_det_bnd_lst;
in principle work provided table not empty commented maxx.
however, proper implementation use sequence , such plain case consider trigger.
it one:
create sequence channel_dept_brand_seq start 1 nomaxvalue minvalue 1 nocycle; create or replace trigger bir_channel_dept_brand_list before insert on channel_dept_brand_list each row begin :new.channel_dept_brand_list_id := channel_dept_brand_seq.nextval; :new.create_ts := sysdate; end; /
your solution create problems in multi-user environment when several sessions call procedure @ same time.
Comments
Post a Comment