PL/SQL中,select into是配对使用的,并且使用select into 是返回的记录数 必须是有且仅有一条 如果返回的结果是多条的话需要使用游标或数组来实现
select t.* from t_exp_hd t where t.cd_express = &aa;
楼上的可以手工输入参数,如果要是用程序去掉神马的,就存储过程吧,加个into
用程序块时,select需要将查找出来的字段into进定义的变量(不能少) declare n varchar2(10):='战士干1'; ab int; begin select id into ab from t_test where name=n; dbms_output.put_line(ab); end; 如果查询的是多字段的话,要这样 declare n varchar2(10):='战士干1'; a int; b varchar2(50); c int; d int; e date; begin select * into a,b,c,d,e from t_test where name=n; dbms_output.put_line(a||b||c||d||e); end;
要是直接查询,就直接在sql窗口中查询就可以。 如果要卸载存储过程中,要用select……into……赋值查询, 将结果输入到另外一个参数中然后输出这个参数,类似下面 这样; declare a date; begin select sysdate into a from dual; dbms_output.put_line(a); end;
如果返回的结果是多条的话需要使用游标或数组来实现
declare
n varchar2(10):='战士干1';
ab int;
begin
select id into ab from t_test where name=n;
dbms_output.put_line(ab);
end;
如果查询的是多字段的话,要这样
declare
n varchar2(10):='战士干1';
a int;
b varchar2(50);
c int;
d int;
e date;
begin
select * into a,b,c,d,e from t_test where name=n;
dbms_output.put_line(a||b||c||d||e);
end;
如果要卸载存储过程中,要用select……into……赋值查询,
将结果输入到另外一个参数中然后输出这个参数,类似下面
这样;
declare
a date;
begin
select sysdate into a from dual;
dbms_output.put_line(a);
end;