DECLARE @i int
        SELECT @i = COUNT(*) FROM AttachmentGroup WHERE groupId = @gid
        IF @i = 0
          INSERT INTO AttachmentGroup(groupId) VALUES(@gid)

解决方案 »

  1.   


    ------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;
      

  2.   


    用OracleParameter的方式,是不是把v_gid := &gid;删除了就行啊?
      

  3.   

    declare
    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;
      

  4.   

    declare 
    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;