在 PL/SQL 我定义了两个变量
v_boolean  BOOLEAN := fase ;
v_null  int := 10 ;下面有一个 表达式
v_boolean = to_date('2009-07-06','yyyy-mm-dd')  between  to_date('2009-07-01','yyyy-mm-dd') and to_date('2009-07-31','yyyy-mm-dd')  ;请问:这时 v_boolean 的值是什么 ?
      如果不能这样写,那  v_boolean  := v_null  is null ;  这个表达式怎么就能返回 true 呢?请高手指教!!!

解决方案 »

  1.   

    to_date('2009-07-06','yyyy-mm-dd')  between  to_date('2009-07-01','yyyy-mm-dd') and to_date('2009-07-31','yyyy-mm-dd')
    只能当条件,不能当表达式。
    declare v_boolean BOOLEAN ;
    begin
    if to_date('2009-07-06','yyyy-mm-dd')  between  to_date('2009-07-01','yyyy-mm-dd') and to_date('2009-07-31','yyyy-mm-dd')
    then
    v_boolean:=true;
    end if;
    if v_boolean =true
    then
    dbms_output.put_line('true');
    end if;
    end;
      

  2.   

    不太明白
    我的例子create or replace procedure tttt is
        a boolean;
        v_null  int := 10 ; begin
        a := to_date('2009-07-06', 'yyyy-mm-dd') between
             to_date('2009-07-01', 'yyyy-mm-dd') and
             to_date('2009-07-31', 'yyyy-mm-dd');
        if a = true then
            dbms_output.put_line('t');
        else
            dbms_output.put_line('f');
        end if;
       
        a  := v_null  is null;
        
        if a = true then
            dbms_output.put_line('t');
        elsif a = false then 
            dbms_output.put_line('f');
        elsif a is null then
            dbms_output.put_line('null');
        else
          null;    
        end if;
    end tttt;
    结果
    t --因为日期在指定区间内
    f --因为v_null不为空
      

  3.   


    PLSQL中比较运算符没有 between   and
      

  4.   

    SQL> declare
      2   v_boolean BOOLEAN ;
      3  begin
      4  v_boolean:= to_date('2009-07-06','yyyy-mm-dd')  between  to_date('2009-07-01','yyyy-mm-dd') and
     to_date('2009-07-31','yyyy-mm-dd');
      5  if v_boolean then
      6  dbms_output.put_line('true');
      7  else
      8  dbms_output.put_line('false');
      9  end if;
     10  end;
     11  /
    truePL/SQL 过程已成功完成。已用时间:  00: 00: 00.01
    SQL> 
      

  5.   

    明白了,between and 可以做为表达式的
    就像楼上朋友写的那样