-1

具有 pk 和状态列的表,其值为“Y”、“N”、“NULL”

询问:

获取状态列为“Y”的记录计数,如果该计数超过记录总数的 1%,则不删除,否则删除表中的记录。

我试过这样

Declare   
  v_count Number;   
  v_count1 Number;   
BEGIN   
  v_count := select count(*) from temp; 
  v_count1 := select count(*) from temp where status = 'Y' ;

  v_count := v_count + ((0.1) * (v_count))

  if (v_count1 > v_count)
  {
    insert into  temp1 values(pk,status)
  } 
  else
  {   
    Delete from temp ;
  }
END;
4

1 回答 1

0
Declare   
v_count Number;   
v_count1 Number;   
BEGIN   
select count(*) into v_count from temp; 
select count(*) into v_count1 from temp where status = 'Y' ;

v_count := v_count + ((0.01) * (v_count))

if (v_count1 > v_count)
{
  insert into  temp1 values(pk,status)
} 
else
{   
  Delete from temp ;
}
END;

像这样更正你的函数 sql 查询.......享受

于 2012-12-18T11:22:15.580 回答