写了一个存储过程,定义了一个游标,需要在游标中的sql
传递变量(这个变量可以是存储过程传递 或者也可以是自己定义)
以下是程序前部分create or replace procedure insertToForDay(
findDay varchar:= to_char(sysdate-1,'yyyy-mm-dd')
)
AS---声明:一天中PV和IP的总数---
countPV  count_list.list_pv%type;
countIP  count_list.list_IP%type;---设置查询PV游标---
CURSOR listCurPV IS
    Select sum(list_pv) as countPV
    From Count_list 
    where to_char(LIST_TIME,'yyyy-mm-dd') like '%sysdate-1%';
    ....................

解决方案 »

  1.   

    需要传变量的地方是
    create or replace procedure insertToForDay(
    时间变量名 varchar:= to_char(sysdate-1,'yyyy-mm-dd')
    )
    AS---声明:一天中PV和IP的总数---
    countPV  count_list.list_pv%type;
    countIP  count_list.list_IP%type;---设置查询PV游标---
    CURSOR listCurPV IS
        Select sum(list_pv) as countPV
        From Count_list 
        where to_char(LIST_TIME,'yyyy-mm-dd') like '%时间变量%';
      

  2.   

    --改为:
    create or replace procedure insertToForDay(
    时间变量名 varchar:= to_char(sysdate-1,'yyyy-mm-dd')
    )
    AS---声明:一天中PV和IP的总数---
    countPV  count_list.list_pv%type;
    countIP  count_list.list_IP%type;---设置查询PV游标---
    CURSOR listCurPV IS
        Select sum(list_pv) as countPV
        From Count_list 
        where to_char(LIST_TIME,'yyyy-mm-dd')=时间变量 ;