存储过程支持ddl的sql,
应该是可以的

解决方案 »

  1.   

    刚刚测试了一下
    CREATE OR REPLACE PROCEDURE ll_05  IS
    v_sql varchar2(200);
    BEGIN
       v_Sql:='CREATE SEQUENCE S_ll_05  START WITH 1  MAXVALUE 999  MINVALUE 1';
      execute immediate v_sql;
    END ll_05;
    /不过由于权限不够没有执行成功
      

  2.   

    换成dba用户登录后上面存储过程执行成功
      

  3.   

    我在oracle以NN用户名登录的.用户隶属于DBA可以吗?
      

  4.   

    CREATE OR REPLACE PROCEDURE ll_05  IS
    v_sql varchar2(200);
    BEGIN
       v_Sql:='CREATE SEQUENCE S_ll_05  START WITH 1  MAXVALUE 999  MINVALUE 1';
      execute immediate v_sql;
    END ll_05;
    /SQL> exec ll_05;PL/SQL procedure successfully completed.
    即可
      

  5.   

    那我能在另一个存储过程中exec ll_05吗?我想在执行完ll_05后就在另一个存储过程中调用ll_05.nextval了.
      

  6.   


    下面是我在另一个存储过程调用 pro_basic_inter_sequence_apps,可是编译不过去.
    create or replace procedure noahark.Pro_basic_inter_entity_apps as  v_entitycode     tbl_basic_inter_entity_apps.centitycode%type;
     v_entitytypename tbl_basic_inter_entity_apps.centityname%type;
     v_bisend         tbl_basic_inter_entity_apps.bisend%type;  
     
    exec pro_basic_inter_sequence_apps;
     cursor c1 is
        select centitycode,casstypecode,ire from noahark.asstype_apps;
    beginopen c1;
    for i in 1..4 loop
    fetch c1 into v_entitycode,v_entitytypename,v_bisend;
    if v_bisend is null then
     v_bisend := 1;
    end if;
    insert into tbl_basic_inter_entity_apps(id,centitycode,centityname,ilevel) values( Pro_basic_inter_SEQUENCE_apps.nextv_entitycode,v_entitytypename,v_bisend);
    COMMIT;
    end loop;
    close c1;
    end;
      

  7.   

    create or replace procedure noahark.Pro_basic_inter_entity_apps as  v_id             tbl_basic_inter_entity_apps.centitycode%type;
     v_entitycode     tbl_basic_inter_entity_apps.centitycode%type;
     v_entitytypename tbl_basic_inter_entity_apps.centityname%type;
     v_bisend         tbl_basic_inter_entity_apps.bisend%type;  
     
    exec noahark.pro_basic_inter_sequence_apps;
     cursor c1 is
        select id,centitycode,casstypecode,ire from noahark.asstype_apps;
    beginopen c1;
    for i in 1..4 loop
    fetch c1 into v_id,v_entitycode,v_entitytypename,v_bisend;
    if v_bisend is null then
     v_bisend := 1;
    end if;
    insert into tbl_basic_inter_entity_apps(id,centitycode,centityname,ilevel) values(pro_basic_inter_sequence_apps.nextval, v_entitycode,v_entitytypename,v_bisend);
    COMMIT;
    end loop;
    close c1;
    end;
    高手给指点指点哪里有错误.谢谢了.
      

  8.   

    什么错误啊
    是否pro_basic_inter_sequence_apps对象不存在
    为什么要在存储过程里面创建序列阿
    直接用脚本都创建好就行了
      

  9.   

    insert into tbl_basic_inter_entity_apps(id,centitycode,centityname,ilevel)
    select pro_basic_inter_sequence_apps.nextval,
    centitycode,casstypecode,
    nvl(ire,1) from noahark.asstype_apps这样一句话就可以实现了
    游标,存储过程都可以省了
      

  10.   

    icedut(冰)你有MSN吗?可以跟你联系一下吗?
      

  11.   

    因为我是刚用三四天的ORACLE,有些地方还用不好,希望向你学习学习.
      

  12.   

    create or replace procedure noahark.Pro_basic_inter_entity_apps as begin
    exec pro_basic_inter_sequence_apps;
    insert into tbl_basic_inter_entity_apps(id,centitycode,centityname,ilevel)
    select pro_basic_inter_sequence_apps.nextval,
    centitycode,casstypecode,
    nvl(ire,1) from noahark.asstype_apps;end;
    这样写不行,编译不过去.
      

  13.   

    如果不在另一个存储过程中执行PRO_BASIC_INTER_SEQUENCE_APPS的话,能在另一个存储过程中直接调用PRO_BASIC_INTER_SEQUENCE_APPS.NEXTVAL吗? 如果用游标,你看看我上边的程序哪有问题,
    现在只差这个ID号了.谢谢了.
      

  14.   

    exec pro_basic_inter_sequence_apps;
    insert into tbl_basic_inter_entity_apps(id,centitycode,centityname,ilevel)
    select pro_basic_inter_sequence_apps.nextval,
    centitycode,casstypecode,
    nvl(ire,1) from noahark.asstype_apps;--编译的时候,pro_basic_inter_sequence_apps序列是不存在的
    所以汇报错误
    序列最好先创建
      

  15.   

    exec pro_basic_inter_sequence_apps;存储过程的名字和序列的相同么你先创建序列在写存储过程序列还灭有创建,当然会有错误
      

  16.   

    create or replace procedure noahark.Pro_basic_inter_entity_apps as 
     v_id             tbl_basic_inter_entity_apps.centitycode%type;
     v_entitycode     tbl_basic_inter_entity_apps.centitycode%type;
     v_entitytypename tbl_basic_inter_entity_apps.centityname%type;
     v_bisend         tbl_basic_inter_entity_apps.bisend%type;
     --创建序列  
     create or replace procedure Pro_basic_inter_SEQUENCE_apps as
      v_sql varchar(200);
    begin
    v_sql:='create sequence seq_name minvalue 1 maxvalue 9999999 start with 1increment by 1';
    execute immediate v_sql;
    end pro_basic_inter_SEQUENCE_apps;
    exec pro_basic_inter_SEQUENCE_apps; 
    --创建游标 
     cursor c1 is
        select pro_basic_inter_sequence_apps.nextval,centitycode,casstypecode,ire from noahark.asstype_apps;
    beginopen c1;
    for i in 1..4 loop
    fetch c1 into v_id,v_entitycode,v_entitytypename,v_bisend;
    if v_bisend is null then
     v_bisend := 1;
    end if;
    insert into tbl_basic_inter_entity_apps(id,centitycode,centityname,ilevel) values(v_id,v_entitycode,v_entitytypename,v_bisend);
    COMMIT;
    end loop;
    close c1;
    end;这个是我用游标写的存储过程,麻烦你帮我看看是哪里的错误?谢谢了
      

  17.   

    存储过程里面怎么还有一个存储过程create or replace procedure Pro_basic_inter_SEQUENCE_apps as
      v_sql varchar(200);
    begin
    v_sql:='create sequence seq_name minvalue 1 maxvalue 9999999 start with 1increment by 1';
    execute immediate v_sql;
    end pro_basic_inter_SEQUENCE_apps;
    --创建存储过程exec pro_basic_inter_SEQUENCE_apps; 
    --执行
    insert into tbl_basic_inter_entity_apps(id,centitycode,centityname,ilevel)
    select seq_name.nextval,
    centitycode,casstypecode,
    nvl(ire,1) from noahark.asstype_apps;
    --应该就是你要的结果了吧
      

  18.   

    create or replace procedure noahark.Pro_basic_inter_entity_apps as 
    begin
    insert into tbl_basic_inter_entity_apps(id,centitycode,centityname,ilevel)
    select seq_name.nextval,
    centitycode,casstypecode,
    nvl(ire,1) from noahark.asstype_apps;end;
    --如果你想用存储过程,这样写应该就可以了
      

  19.   

    我执行,SEQUENCE时说我的权限不足.
      

  20.   

    那怎么呀?我现在在另一个用户下,不过隶属于DBA用户.
      

  21.   

    "创建SEQUENCE能否在存储过程中建?我想每个存储过程都创建一个SEQUENCE."为什么要这样做?你将SEQUENCE用在什么地方?应该是“每次调用存储过程都去引用一个SEQUENCE”,而不是重新生成一个SEQUENCE!存储过程中可以使用动态语句生成SEQUENCE,但是这样做法是一种既不负责的做法!SEQUENCE不是数据,而是提供序列的工具,使用它的目的就是自动生成不重复的值,如果每次启动存储过程都生成一个不同的SEQUENCE,怎么保证它们得到的值不重复呢?!