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;
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;
解决方案 »
- oracle 11g 如何获取管理界面的预警信息
- Oracle 改为一个分组语句!
- 用Odt.net连oracle,一直无法打开连接,若先用pl/sql连接后,就可以用Opt.net连接了
- 初学oracle,求一函数算法
- 怎么知道哪些表正在被查询?
- EXCEL上传扫描去重效率问题
- 朋友能告诉我怎么做吗?
- 我用户下的存储过程,怎么分配权限给另一个用户去执行我包下的存储过程呢?在线等..最后10分
- 应用程序在客户端访问服务器的Oracle,是不是客户端一定要装Oracle Client?
- 请高手帮我看一下这个程序错在那儿?(在线等)
- 初学oracle,调用过程出错,思考很久没有答案,望大大指教,谢谢!
- SQL多表查询问题
a int;
begin
select max(ec_id) into a from easybuy_comment;
--DDL在PL/SQL中只能动态执行
execute immediate
'create sequence commentid
minvalue 1
maxvalue 999999
start with '|||a|'
increment by 1
case 20';
end;
minvalue 1 -- 最小值
maxvalue 999999 -- 最大值
start with 1 -- 开始值
increment by 1 --每次增长值
cache 20; --缓存大小
declare
a int;
v_sql varchar2(500);
begin
select max(ec_id) into a from easybuy_comment;
--ddl语句不能直接在plsql里执行,要通过动态语句执行
v_sql := 'create sequence commentid minvalue 1 maxvalue 9999 start with ' || a ||
' increment by 1 case 20';
execute immediate v_sql;
end;
create or replace procedure p_createseq(tablename in varchar2) is
strsql varchar2(500);
a NUMBER(4) := 0;
begin
select 100 into a from dual;
strsql := 'create sequence seq_' || tablename ||
' minvalue 1000 maxvalue 99999999 start with 1000 increment by ' || a ||
' nocache';
execute immediate strsql;
end p_createseq;
create or replace procedure p_createseq(tablename in varchar2) is
strsql varchar2(500);
a NUMBER(4) := 0;
begin
select max(ec_id) into a from easybuy_comment;
strsql := 'create sequence seq_' || tablename ||
' minvalue 1000 maxvalue 99999999 start with 1000 increment by ' || a ||
' nocache';
execute immediate strsql;
end p_createseq;
create or replace procedure p_createseq(tablename in varchar2) is
strsql varchar2(500);
a NUMBER(4) := 0;
begin
select max(ec_id) into a from easybuy_comment;
strsql := 'create sequence seq_' || tablename ||
' minvalue 1000 maxvalue 99999999 start with 1000 increment by ' || a ||
' nocache';
execute immediate strsql;
end p_createseq;
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 using a;
end p_createseq;
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;
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;