怎么把select出的参数 传入到下一个sql语句中?
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.
------解决方案--------------------declare
newId number(18);
BEGIN
select Base_ID.nextval INTO newId from dual;
insert into Base(ID) values(newId);
END;
PL/SQL所有变量必须声明在declare和begin之间,和T-SQL不一样。
------解决方案--------------------
18表示变量长度,PL/SQL中变量是需要有类型和长度的。
------解决方案--------------------写的数据块就有问日,变量的声明是放在declare里面的,在begin之前的