DECLARE @i int
SELECT @i = COUNT(*) FROM AttachmentGroup WHERE groupId = @gid
IF @i = 0
INSERT INTO AttachmentGroup(groupId) VALUES(@gid)
SELECT @i = COUNT(*) FROM AttachmentGroup WHERE groupId = @gid
IF @i = 0
INSERT INTO AttachmentGroup(groupId) VALUES(@gid)
------try it
declare
i number;
v_gid AttachmentGroup.groupId%type;
begin
v_gid := &gid;
select count(*) into i from AttachmentGroup WHERE groupId = v_gid;
if i = 0 then
insert into AttachmentGroup (groupId) VALUES (v_gid);
end if;
commit;
end;
用OracleParameter的方式,是不是把v_gid := &gid;删除了就行啊?
i number;
gid AttachmentGroup.groupId%type;
begin
gid:='赋值';
SELECT COUNT(*) into i FROM AttachmentGroup WHERE groupId = gid;
if i=0 then
INSERT INTO AttachmentGroup(groupId) VALUES(gid);
end if;
end;
i number;
begin
select count(*) into i from attachmentgroup where groupid=@gid;
if i=0 then
insert into attachmentgroup(groupid) values (@gid);
end if;
end;