要用动态sql来实现!!你想通过简单的拼接是无法实现的!

解决方案 »

  1.   

    我在VB.net中使用,动态构成ADO.net的sql命令是可以做到的(在VB.net中先把sql命令拼接好就行),但不知道ADO.net的一个OleCommand对象的CommandText能否同时包含多条sql命令,如果可以,是不是用分号分开就可?请大家继续顶!
      

  2.   

    create procedure pro(p_col in varchar2)
    as
    v_col varchar2(50):=p_col||',';
    num number;
    type mycursor is ref cursor;
    v_sor mycursor;
    str varchar2(100);
    begin
    num:=length(v_col);
    str:='select ';
    for i in 1..100 loop
    num:=instr(v_col,',',1,i);
    if num=length(v_col) then
    exit;
    end if;
    if i=1 then
    str:=str||'col'||substr(v_col,1,instr(v_col,',',1,1)-1)||',';
    end if;
    str:=str||'col'||substr(v_col,instr(v_col,',',1,i-1)+1,instr(v_col,',',1,i)-1)||',';
    end loop;
    str:=substr(str,1,length(str)-1);
    open v_sor for str||' from TEST…';
    end;
    /
      

  3.   

    先动态生成要select的字符串,在select 字符串---
    也可以到存放字段的系统表去取的!