Home > database >  The oracle stored procedure reset sequence problems every day
The oracle stored procedure reset sequence problems every day

Time:09-22

The CREATE OR REPLACE PROCEDURE p_reset_seq IS
/*
The reset sequence ID
*/
PN_ID NUMBER;
N number (10);
TSQL varchar2 (100);

The BEGIN
- reset sequence 1
The select seq_finance_income_id. Nextval into n from dual;
N:=- (n - 1);
TSQL:='alter sequence seq_finance_income_id increment by' | | (n);
The execute immediate TSQL;

The select seq_finance_income_id. Nextval into n from dual;
TSQL:='alter sequence seq_finance_income_id increment by 1'. //run here sometimes error is what problem?
The execute immediate TSQL;
commit;
2 - reset sequence
The select seq_finance_settlement_id. Nextval into n from dual;
N:=- (n - 1);
TSQL:='alter sequence seq_finance_settlement_id increment by' | | (n);
The execute immediate TSQL;

The select seq_finance_settlement_id. Nextval into n from dual;
TSQL:='alter sequence seq_finance_settlement_id increment by 1'.
The execute immediate TSQL;

commit;
END p_reset_seq;

CodePudding user response:

TSQL:='alter sequence seq_finance_income_id increment by' | | (n);
the execute immediate TSQL;

The select seq_finance_income_id. Nextval into n from dual;
TSQL:='alter sequence seq_finance_income_id increment by 1'.//run here sometimes error is what problem?
the execute immediate TSQL;
commit;
2 - reset sequence
The select seq_finance_settlement_id. Nextval into n from dual;
N:=- (n - 1);
TSQL:='alter sequence seq_finance_settlement_id increment by' | | (n);



Above the red line 3, there are problems,
After 1 and 3, by to write a space, by joining together into by 1, no Spaces is by1.
2,//to change - the comments in the SQL statement is/* */or -, and can not be//

CodePudding user response:

In addition there is a problem, you should pay attention to the

TSQL:='alter sequence seq_finance_income_id increment by' | | (n);

N=0, you have to deal with,

  • Related