目的仅仅要求能做变量赋值,然后以变量为条件查询表。要求能直接看到记录内容

解决方案 »

  1.   

    oracle中的函数和存储过程能不能达到这样的效果,比如,我在PL/SQL中写上  select * from tablea where condition1 = 1 and condition2 = 'aaa'因为条件1和'aaa'未知,我现在需要写在函数或存储过程中,但好像函数或存储过程返回的结果集不能像SELECT语句那样运行后直接显示,那该如何实现?是不是oracle不支持这个???
      

  2.   

    cursor aa(a in number,b in varchar2) is
    select * from tablea where condition1 = a  and condition2 = b;
    for v in cursor (1,'aaa') loop
      ........
    end loop;
      

  3.   

    DECLARE
       v_condition1 tablea.condition1%TYPE;
       v_condition2 tablea.condition2%TYPE;
        v_temp tablea%ROWTYPE;
    BEGIN
       SELECT * INTO v_temp FROM tablea 
       WHERE condition1 = v_condition1 and condition2 = v_condition2 ;
       DBMS_OUTPUT.PUT_LINE
       (v_temp.v_condition1||'--'||v_temp.v_condition2);
    END;
      

  4.   

    推荐楼主看一下PL/SQL程序设计PS:下载地址  http://www.itpub.net/256746.html
      

  5.   

    select * from tablename where col=&变量名
    直接执行就可以
      

  6.   

    DECLARE 
       v_condition1 tablea.condition1%TYPE; 
       v_condition2 tablea.condition2%TYPE; 
        v_temp tablea%ROWTYPE; 
    BEGIN 
       SELECT * INTO v_temp FROM tablea  
       WHERE condition1 = v_condition1 and condition2 = v_condition2 ; 
       DBMS_OUTPUT.PUT_LINE 
       (v_temp.v_condition1 ¦ ¦'--' ¦ ¦v_temp.v_condition2); 
    END;