麻烦问一下各位 就是我写了一个存储过程
create or replace procedure pro_test(id_ in varchar2,
name_ out varchar2,
age_ out varchar2,
email_ out varchar2,
) is
begin
select a.name,a.age,a.email into name_,age_,email_ from AA a where id=id_;
union
select b.name,b.age,b.email into name_,age_,email_ from BB b where id=id_;
union
select c.name,c.age,c.email into name_,age_,email_ from CC c where id=id_;
end;
exception
when others then
rollback;
end pro_test;
就是有AA,BB,CC三张表 一个学生的id 有可能AA表有 也有可能BB表才有 我不知道这个学生的id 在哪张表里面 所以要放在三张表里面查 现在我执行这个存储过程的时候 报into有错 我想是不是不能重复的赋值给name_,age_,email_ 麻烦问一下 这个要怎么写 才能把最后查出来的name,age,email赋值给name_,age_,email_ 谢谢了
create or replace procedure pro_test(id_ in varchar2,
name_ out varchar2,
age_ out varchar2,
email_ out varchar2,
) is
begin
select a.name,a.age,a.email into name_,age_,email_ from AA a where id=id_;
union
select b.name,b.age,b.email into name_,age_,email_ from BB b where id=id_;
union
select c.name,c.age,c.email into name_,age_,email_ from CC c where id=id_;
end;
exception
when others then
rollback;
end pro_test;
就是有AA,BB,CC三张表 一个学生的id 有可能AA表有 也有可能BB表才有 我不知道这个学生的id 在哪张表里面 所以要放在三张表里面查 现在我执行这个存储过程的时候 报into有错 我想是不是不能重复的赋值给name_,age_,email_ 麻烦问一下 这个要怎么写 才能把最后查出来的name,age,email赋值给name_,age_,email_ 谢谢了
我写的那个付3次值了 不知道这个应该怎么写了
name_ out varchar2,
age_ out varchar2,
email_ out varchar2,
) is
begin
for cur in (
select a.name,a.age,a.email from AA a where id=id_;
union
select b.name,b.age,b.email from BB b where id=id_;
union
select c.name,c.age,c.email from CC c where id=id_) loop
.......
.......
end loop;
end;
exception
when others then
rollback;
end pro_test;
select a.name,a.age,a.email from AA a where id=id_;
union
select b.name,b.age,b.email from BB b where id=id_;
union
select c.name,c.age,c.email from CC c where id=id_) loop
name_ := cur.name;
age_ := cur.age;
email_:= cur.email; end loop;
select a.mc,a.nl,a.dzyj from AA a where id=id_;
union
select b.name,b.age,b.email from BB b where id=id_;
union
select c.name,c.age,c.email from CC c where id=id_;这种的话 name_ := cur.name;
age_ := cur.age;
email_:= cur.email; 这个好像就不对吧
不如 有一张表叫name 有一张表的name是mc (名称)
也就是说 AA表 列 mc(名称), nl(年龄),dzyj(电子邮件)
BB表 列 name(名称),age(年龄),email(电子邮件)
CC表 列 mc(名称), age(年龄),email(电子邮件)
这种的话 实际我的查询写的是 select a.mc,a.nl,a.dzyj from AA a where id=id_;
union
select b.name,b.age,b.email from BB b where id=id_;
union
select c.mc,c.age,c.email from CC c where id=id_;这种的话 name_ := cur.name;
age_ := cur.age;
email_:= cur.email; 这个好像就不对吧
select a.name,a.age,a.email from AA a where id=id_;
union
select b.name,b.age,b.email from BB b where id=id_;
union
select c.name,c.age,c.email from CC c where id=id_) loop
name_ := cur.name;
age_ := cur.age;
email_:= cur.email; end loop;