大家好,问一个简单的select count 问题。做了一个资源有限的ID ,如果设置id被用设置状态为1,未用的id设置状态为 0更新记录前先判断是否有空闲的id数目 ,如果数目大于0,就更新,如果等于0,就create or replace procedure test(total out number,id...)
is
...
begin
select count(*) as total from table_name where status=0;
if total>0 then
.... end if;
if total=0 then
...
end if;
end;
/貌似select count(*) as total from table_name where status=0;有问题,我想把状态为1的记录条数赋给total,不知道有什么方法?请大家多多指导
is
...
begin
select count(*) as total from table_name where status=0;
if total>0 then
.... end if;
if total=0 then
...
end if;
end;
/貌似select count(*) as total from table_name where status=0;有问题,我想把状态为1的记录条数赋给total,不知道有什么方法?请大家多多指导
解决方案 »
- 触发器的问题
- ODI创建JKM MySQL Simple知识模块,<%=snpRef.getInfo("SRC_PASS")%>不能被解释?
- to_char中的第三个参数怎么把中文日期转换为英文
- 关于数据存储过程 帮帮我
- Oracle中如何在存储过程中创建和删除表索引?
- 更改表的所有者,请高手进来看看(100分),不够再加
- 一个操作执行了10多个小时还没有完?不知为什么。
- 请教:系统当前时间与表中时间字段如何进行比较?
- 一个想不通的问题 case when null=null then 222 else 0 end ...
- 多个连续表名实现在一个视图中进行查询?
- 关于dsn数据源的问题,请进
- oracle查询表空间问题
select count(*) into total from table_name where status=0;
set serverout on
declare
v_count number;
begin
select count(1) into v_count from dual;
dbms_output.put_line(v_count);--如果是动态SQL
execute immediate 'select count(1) from dual' into v_count;
dbms_output.put_line(v_count);
end;
select count(*) into total from table_name where status=0;