0

桌子

Id
Count

我想编写一个过程以Count在表中以' Id'为键查找''。得到' count'后,我必须将其递增并在表中更新回' Id'。如何在不使用游标的情况下使用过程编写此代码。

我想要一个像下面这样的简单程序,但它没有执行。它说程序成功但编译错误。帮帮我。

create or replace PROCEDURE newpro( inId IN NUMBER, outcount OUT NUMBER) is
select COUNT into outcount from Table1 WHERE ID= inId ;
BEGIN 
outcount := outcount +1; 
update Table1 set COUNT = outcount WHERE ID = inId ; 
END;
4

2 回答 2

4
UPDATE tableName
SET "Count" = "Count" + 1
WHERE ID = valueHere
于 2012-10-29T08:26:43.447 回答
1

试试这个

create or replace Procedure Newpro
(
  Inid     in number,
  Outcount out number
) is
begin
  select count + 1
    into Outcount
    from Table1
   where Id = Inid;

  update Table1
     set count = Outcount
   where Id = Inid;   
end;
于 2012-10-30T09:47:04.430 回答