本帖最后由 qiang521qiang 于 2010-01-14 17:35:33 编辑

解决方案 »

  1.   

    select distinct mbrid from  fi06
                       where ( mbrid='1000' and dos >= dos1 and dos <= dos30);
    单引号都去掉,已经是date类型的了
      

  2.   


    不行吧  我这个是在动态游标中  我 for后面还有一对单引号呢? open fi_cur1 for ' select distinct mbrid from  fi06
                       where ( mbrid=''1000'' and dos >= '||dos1||' and dos <= '||dos30||')';
      

  3.   

    mbrid 是 Varchar2 的
    dos 是 date 的
      

  4.   

    你这个不属于动态游标。mbrid已经改为一个单引号的固定的了。
    动态游标一般是表名、字段名是变量才需要用到。值是变量的话用不着的。
      

  5.   


    create or replace procedure test_p is
    type tcur is ref cursor;
    fi_cur1 tcur;
    dos1 date;
    dos30 date;
    name varchar2(20);
    begin
    dos1 := to_date('2006-01-01','yyyy-mm-dd');
    dos30 := to_date('2006-11-01','yyyy-mm-dd');
    name := 'fi06';
      open fi_cur1 for ' select distinct mbrid from  '||name||'
                       where ( mbrid=''1000'' and dos >= '||dos1||' and dos <= '||dos30||')';
    end test_p;
      

  6.   


    这样啊,那你的to_date得写到sql中去,把你的'2009-01-01'作为参数
    ||连接得是字符串。
      

  7.   

    你的意思是  
    create or replace procedure test_p is
    type tcur is ref cursor;
    fi_cur1 tcur;
    dos1 varchar2(20);
    dos30 varchar2(20);
    name varchar2(20);
    begin
    dos1 := '2006-01-01';
    dos30 := '2006-11-01';
    name := 'fi06';
      open fi_cur1 for ' select distinct mbrid from  '||name||'
                       where ( mbrid=''1000'' and dos >= '||to_date(dos1,'yyyy-mm-dd')||' and dos <= '||to_date(dos30,'yyyy-mm-dd')||')';
    end test_p;但是还是是不可以的还是报 缺失右括号
      

  8.   

     ' select distinct mbrid from  '||name||'
                       where ( mbrid=''1000'' and dos >= to_date('''||dos1||''',''yyyy-mm-dd'') and dos <= to_date('''||dos30||''',''yyyy-mm-dd''))';dos1,dos30是字符串。
      

  9.   

    create or replace procedure test_p 
    is
    type tcur is ref cursor;
    fi_cur1 tcur;
    dos1 date;
    dos30 date;begindos1 := to_date('2006-01-01','yyyy-mm-dd');
    dos30 := to_date('2006-11-01','yyyy-mm-dd');
      open fi_cur1 for ' select distinct mbrid from  fi06 where ( mbrid='||chr(39)||'1000'||chr(39)|| 'and dos >= '||dos1||' and dos <= '||dos30||')';end test_p;
      

  10.   

    忘记了问你dos列的数据类型是什么了?如果是varchar2类型的话,那么要转一下型(to_date)。
    转成和dos1,dos30一样的格式。