用程序必须要用select into不能简单的select : 如: declare a varchar2(100); b number; BEGIN select Date_ID,pmHoPrepSuccLteIntraF*pmHoPrepSuccLteInterF into a,b from SGHO; dbms_output.put_line(a||b); END ;
能不能帮忙解释一下语句的含义,多谢declare a varchar2(100); b number; BEGIN select Date_ID,pmHoPrepSuccLteIntraF*pmHoPrepSuccLteInterF into a,b from SGHO; dbms_output.put_line(a||b); END ;
能不能帮忙具体解释一下语句的用途,多谢 declare a varchar2(100); b number; BEGIN select Date_ID,pmHoPrepSuccLteIntraF*pmHoPrepSuccLteInterF into a,b from SGHO; dbms_output.put_line(a||b); END ;
露珠想学习plsql可以找一本基础的课本进行学习。 随便写一段代码吧: declare i1 varchar2(16); i2 varchar2(16); begin for c1 in(select area_id from dim_area_no) loop select tel into i1 from tbl_tel1 where area=c1.area_id; select tel into i2 from tbl_tel2 where area=c1.area_id; if i1<>i2 then dbms_output.put_line(i1); end if ; end loop; end;
declare 变量定义; begin 这里写上你的sql语句 end;
使用begin end 运行select 时,不能单单地使用select,必须使用select into 。声明一个变量,将查询到的结果 into 赋给一个变量。
如11楼所言 declare 变量定义; begin sql语句 end; 需要注意的是begin end 运行select 时,使用select into 。否则你执行一个select毫无意义啊
如:
declare
a varchar2(100);
b number;
BEGIN
select Date_ID,pmHoPrepSuccLteIntraF*pmHoPrepSuccLteInterF into a,b from SGHO;
dbms_output.put_line(a||b);
END ;
a varchar2(100);
b number;
BEGIN
select Date_ID,pmHoPrepSuccLteIntraF*pmHoPrepSuccLteInterF into a,b from SGHO;
dbms_output.put_line(a||b);
END ;
declare
a varchar2(100);
b number;
BEGIN
select Date_ID,pmHoPrepSuccLteIntraF*pmHoPrepSuccLteInterF into a,b from SGHO;
dbms_output.put_line(a||b);
END ;
从基础语法开始学起吧
注意这里查询出来的值只能为单条记录。
我建议你还是先自己看看书,因为这个是最简单的。
SQL SERVER这点比较方便,直接可以返回结果集合
随便写一段代码吧:
declare
i1 varchar2(16);
i2 varchar2(16);
begin
for c1 in(select area_id from dim_area_no) loop
select tel into i1 from tbl_tel1
where area=c1.area_id;
select tel into i2 from tbl_tel2
where area=c1.area_id;
if i1<>i2 then
dbms_output.put_line(i1);
end if ;
end loop;
end;
变量定义;
begin
这里写上你的sql语句
end;
declare
变量定义;
begin
sql语句
end;
需要注意的是begin end 运行select 时,使用select into 。否则你执行一个select毫无意义啊