declare
a int;
begin
select max(ec_id) into a from easybuy_comment;
create sequence commentid
minvalue 1
maxvalue 999999
start with a
increment by 1
case 20;
end;
------解决方案--------------------
- SQL code
create or replace procedure p_createseq(tablename in varchar2) is /*错误位置在case需要改成cache 这个是正确的 */ strsql varchar2(500); a NUMBER(4) := 0;begin select max(ec_id) into a from easybuy_comment; strsql := 'create sequence seq_' || tablename || ' minvalue 1 maxvalue 9999 start with '||a||' increment by 1 cache 20'; execute immediate strsql;end p_createseq;
------解决方案--------------------
declare
a int;
v_sql varchar2(500);
begin
select max(id) into a from sys_user;
--ddl语句不能直接在plsql里执行,要通过动态语句执行
v_sql := 'create sequence commentid minvalue 1 maxvalue 9999 start with ' || a ||
' increment by 1 cache 20'; --3楼这里写错了 是cache不是case 这个语句应该是没错的
execute immediate v_sql;
end;