比如我有一个表,叫table
然后,我有一个变量a和变量b
现在我要检索变量a是否是在表table中的name列中
如果存在的话,置变量b为1,不存在的话为0
这样该怎么写?
name|sex|……
---------------------------
|
|
|
|
然后,我有一个变量a和变量b
现在我要检索变量a是否是在表table中的name列中
如果存在的话,置变量b为1,不存在的话为0
这样该怎么写?
name|sex|……
---------------------------
|
|
|
|
b:=1;
else
b:=0;
as
b int:=0;
begin
select count(*) into b from table where name=a;
if b=0 then ……
else
……
end if;
end;
create or replace procedure Judge(a in varchar2,b out number) as
v_count number;
begin
select count(*) into v_count from table
where name = 'a';
if v_count > 0 then b := 1;
else b := 0;
end if;
end;