if exists(select * from Product_Category where Commonality=@Commonality and Pid=0 and Title=@Title)
select Id from Product_Category where Commonality=@Commonality and Pid=0 and Title=@Title
else
begin
insert Product_Category(Pid,Title,Commonality, OrderSort)
select 0, @Title, @Commonality,(select isnull(max(OrderSort),0)+1 from Product_Category) as OrderSort
select @@identity
end转换为oracle 尽量的简单·
select Id from Product_Category where Commonality=@Commonality and Pid=0 and Title=@Title
else
begin
insert Product_Category(Pid,Title,Commonality, OrderSort)
select 0, @Title, @Commonality,(select isnull(max(OrderSort),0)+1 from Product_Category) as OrderSort
select @@identity
end转换为oracle 尽量的简单·
if exists(select * from Product_Category where Commonality=@Commonality and Pid=0 and Title=@Title)
select Id from Product_Category where Commonality=@Commonality and Pid=0 and Title=@Title
else
begin
insert Product_Category(Pid,Title,Commonality, OrderSort)
select 0, @Title, @Commonality,(select isnull(max(OrderSort),0)+1 from Product_Category) as OrderSort
select @@identity
end
v_cnt int;
v_seq int;
begin
v_cnt := 0;select count(*) into v_cnt
from Product_Category where Commonality=&Commonality and Pid=0 and Title=&Title;if v_cnt>0 then
insert Product_Category(Pid,Title,Commonality, OrderSort)
select 0, &Title, & Commonality,
(select nvl(max(OrderSort),0)+1 from Product_Category) as OrderSort from dual;
-- select 序列名.currval into v_seq from dual; -- @@identity这句不知道有什么用处
end if;
end
我知道这个是取SQL SERVER 自增列的ID啊,自增列在ORACLE用序列表示的?
select 序列名.currval into v_seq from dual;
v_Commonality Product_Category.Commonality%type;
v_Title Product_Category.Title%type;
num number;
v_id Product_Category.id%type;
begin
select count(*) into num from Product_Category where Commonality=v_Commonality and Pid=0 and Title=v_Title;
if num>0 then
select id into v_id from Product_Category where Commonality=v_Commonality and Pid=0 and Title=v_Title;
else
insert Product_Category(Pid,Title,Commonality, OrderSort)
select 0,v_Title,v_Commonality,(select nvl(max(OrderSort),0)+1 from Product_Category) OrderSort from dual;
---select @@identity 这个自增干什么;
end;