我怎样才能在oracle程序中进行索引

时间:2017-07-26 13:52:31

标签: oracle procedure

这是我的程序:

create or replace PROCEDURE testsub(factTName IN VARCHAR2)
IS
  v_in_char VARCHAR2(100):='id,name,age,cjrq';
  v_result VARCHAR2(200) :='';
begin
  -- split v_in_char,expect cjrq
  -- i want result like t.uuid=uuid and t.uuname=uuname and t.uuage=uuage

  SYS.DBMS_OUTPUT.PUT_LINE(v_result);
end;

2 个答案:

答案 0 :(得分:0)

可能是这样的:

select substr(v_in_char,instr(v_in_char,',',1,3)+1) into v_result 
from dual;

答案 1 :(得分:0)

create or replace PROCEDURE testsub(factTName IN VARCHAR2)
IS
  v_primy_keys VARCHAR2(200) :='';
  cursor primy_key is
    select field_en_name from BASE_FIELD_INFO where base_rpt_id=lower(factTName) and primy_key='true';
  primy_key_row  primy_key%ROWTYPE;
begin
  for primy_key_row in primy_key loop
    IF primy_key_row.field_en_name='CJRQ' THEN
      DBMS_OUTPUT.PUT_LINE('');
    ELSE
      v_primy_keys:=v_primy_keys||'t.'||primy_key_row.field_en_name||'='||primy_key_row.field_en_name||' ';
    END IF;
    v_primy_keys:=v_primy_keys||' and ';
  end loop;
  v_primy_keys:=substr(v_primy_keys,1,length(v_primy_keys)-4);
  dbms_output.put_line(v_primy_keys);
end;