The create or replace procedure PRO_GEN_SEQ_NUM (vkey in varchar2, seqid out varchar) is
V_SVAL VARCHAR2 (8);
V_date VARCHAR2 (8);
V_month VARCHAR2 (4);
V_year VARCHAR2 (4);
V_day VARCHAR2 (4);
V_dateformat VARCHAR2 (20);
V_randomnums VARCHAR2 (20);
The begin
Select (SVAL + 1), ssty, year, month, day INTO V_SVAL, v_dateformat, v_year, v_month, v_day from xtseq WHERE snam=VKEY;
V_randomnums:=substr (v_dateformat, instr (v_dateformat, 'x')); - random digits XXXX
V_dateformat:=substr (v_dateformat, 1, instr (v_dateformat, 'x') - 1); - the date format
If v_dateformat not in (' yymm ', 'yyyymm', 'yyyymmdd', 'yymmdd', 'yyyy) then
V_dateformat:='yyyymm';
End the if;
The select to_char (sysdate, v_dateformat) into V_date from dual;
If v_dateformat='yymm' then
If v_year!=to_char (sysdate, 'yy) then
The update xtseq set SVAL='1', year=to_char (sysdate, 'yy), the month=to_char (sysdate,' mm) where snam=VKEY;
V_SVAL:='1';
Elsif v_year=to_char (sysdate, 'yy) and v_month!=to_char (sysdate, 'mm) then
The update xtseq set SVAL='1', the month=to_char (sysdate, 'mm) where snam=VKEY;
V_SVAL:='1';
End the if;
Elsif v_dateformat='yyyymm' then
If v_year!=to_char (sysdate, 'yyyy) then
The update xtseq set SVAL='1', year=to_char (sysdate, 'yyyy), the month=to_char (sysdate,' mm) where snam=VKEY;
V_SVAL:='1';
Elsif v_year=to_char (sysdate, 'yyyy) and v_month!=to_char (sysdate, 'mm) then
The update xtseq set SVAL='1', the month=to_char (sysdate, 'mm) where snam=VKEY;
V_SVAL:='1';
End the if;
Elsif v_dateformat='yyyymmdd' then
If v_year!=to_char (sysdate, 'yyyy) then
The update xtseq set SVAL='1', year=to_char (sysdate, 'yyyy), the month=to_char (sysdate,' mm), day=to_char (sysdate, 'dd') where snam=VKEY;
V_SVAL:='1';
Elsif v_year=to_char (sysdate, 'yyyy) and v_month!=to_char (sysdate, 'mm) then
The update xtseq set SVAL='1', the month=to_char (sysdate, 'mm), day=to_char (sysdate,' dd ') where snam=VKEY;
V_SVAL:='1';
Elsif v_year=to_char (sysdate, 'yyyy) and v_month=to_char (sysdate,' mm) and v_day!=to_char (sysdate, 'dd') then
The update xtseq set SVAL='1', day=to_char (sysdate, 'dd') where snam=VKEY;
V_SVAL:='1';
End the if;
Elsif v_dateformat='yymmdd then
If v_year!=to_char (sysdate, 'yy) then
The update xtseq set SVAL='1', year=to_char (sysdate, 'yy), the month=to_char (sysdate,' mm), day=to_char (sysdate, 'dd') where snam=VKEY;
V_SVAL:='1';
Elsif v_year=to_char (sysdate, 'yy) and v_month!=to_char (sysdate, 'mm) then
The update xtseq set SVAL='1', the month=to_char (sysdate, 'mm), day=to_char (sysdate,' dd ') where snam=VKEY;
V_SVAL:='1';
Elsif v_year=to_char (sysdate, 'yy) and v_month=to_char (sysdate,' mm) and v_day!=to_char (sysdate, 'dd') then
The update xtseq set SVAL='1', day=to_char (sysdate, 'dd') where snam=VKEY;
V_SVAL:='1';
End the if;
Elsif v_dateformat='yyyy' then
If v_year!=to_char (sysdate, 'yyyy) then
The update xtseq set SVAL='1', year=to_char (sysdate, 'yyyy) where snam=VKEY;
V_SVAL:='1';
End the if;
End the if;
The UPDATE xtseq SET SVAL=V_SVAL WHERE snam=VKEY;
Seqid:=V_date | | trim (to_char (V_SVAL, replace (v_randomnums, 'x', '0')));
- commit;
Seqid:=seqid;
End PRO_GEN_SEQ_NUM;
CodePudding user response:
Oh great god door for helpCodePudding user response:
Please try to personally wrote the first, and then have problems posted write their own code and error description everybody together discuss,Syntax can in MYSQL MYSQL official manual for free,
CodePudding user response:
A word or two, or baidu is better,,