oracle 动态sql select into

好久没写过程了,写的有点生涩!
create or replace function fun_get_reversion_remark(bms_accept_id in varchar2) return varchar2
----根据定单id获取预约备注信息
is
  Result varchar2(512);
  v_yyyymm varchar2(20);
  v_sql varchar2(512);
begin

  v_yyyymm:=Substr(bms_accept_id, 0, 6);
  v_sql:='select bms_accept_detail From bms_accept_form_'||v_yyyymm||' t where sn=65 and t.bms_accept_id='''||bms_accept_id||'''';
  execute immediate v_sql into Result;

  return(Result);

  exception
   WHEN OTHERS THEN
        Result:=null;
        return Result;
end fun_get_reversion_remark;

你可能感兴趣的:(oracle,select into,动态sql)