BEGIN
newId INTEGER
select Base_ID.nextval INTO newId from dual;insert into Base(ID) values(newId);END
但是报错[Err] 
PLS-00103: Encountered the symbol "INTEGER" when expecting one of the following:   := . ( @ % ;
The symbol "; was inserted before "INTEGER" to continue.PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:   ; <an identifier> <a double-quoted delimited-identifier>
The symbol ";" was substituted for "end-of-file" to continue.

解决方案 »

  1.   

    declare
      newId number(18);
    BEGINselect Base_ID.nextval INTO newId from dual;
     
    insert into Base(ID) values(newId);
     
    END;PL/SQL所有变量必须声明在declare和begin之间,和T-SQL不一样。
      

  2.   

    可以了!  再问一下,number(18),18是什么意思,oracle里声明number要限制长度?
      

  3.   

    可以了!  再问一下,number(18),18是什么意思,oracle里声明number要限制长度?18表示变量长度,PL/SQL中变量是需要有类型和长度的。
      

  4.   

    写的数据块就有问日,变量的声明是放在declare里面的,在begin之前的