大家好,请问我想用存储过程编写一个查询A表中savetime时间小时等于当前getdate()小时一致的记录总数,并以返回值返回?请问要怎样写?

解决方案 »

  1.   

    create or replace procedure get_count
    is
    m number;
    begin
        select count(*) into m
          from a 
          where to_char(savetime,'hh')=to_char(sysdate,'hh');
        dbms_output.put_line('总记录数:'||m);
    end get_count;
      

  2.   

    要不要定义一个out变量: m        out VARCHAR2?
      

  3.   


    按照你的意思,这样也可以:create or replace procedure get_count(m out number) 
    is 
    begin 
        select count(*) into m 
          from a 
          where to_char(savetime,'hh')=to_char(sysdate,'hh'); 
    end get_count;
      

  4.   


    直接sql就可以呀select count(1) from tabel1 where trunc(savetime,'hh') = trunc(sysdate,'hh');