如何取出filter_code列中的表达式,当表达式全部满足的时候返回‘0’,失败的时候把表达式的内容给全部返回出去,存在另一张表中,并逐条插入失败原因,返回结果,看那个条件有问题,示例如下
/**
case when user_status_id=1
and x_cust_count=1
and call_duration_nofree>10
and arrear_all_fee<1
and (z_call_count>1 or bill_cust_count_last=1) and user_status_id=1
and x_cust_count=1 and arrear_all_fee<1
and (z_call_count>1 or bill_cust_count_last=1) then '0' else '1' end
*/
我自己写的代码请大神看一下是否正确,没思路了,谢谢
create or replace procedure sp_ceshi_case_lmx
is
--声明变量
v integer;
v_sql varchar2(1000);
begin
for v in (select to_number(t.condition_id)condition_id,t.rule_id,t.filter_code
from TB_EW_M_PAY_CONDIION_bak t
group by to_number(t.condition_id) ,t.rule_id,t.filter_code
order by to_number(t.condition_id) ,t.rule_id,t.filter_code)
loop
v_sql:=v_sql||v.filter_code ||' ' ;
end loop;
execute immediate v_sql;
/**往临时表中插入数据*/
insert into LMX_TB_EW_M_PAY_CONDIION
(
rule_id,
filter_name
)
/**success 返回值'0',fail 返回值 '1'*/
select
rule_id,
case when user_status_id=1
and x_cust_count=1
and call_duration_nofree>10
and arrear_all_fee<1
and (z_call_count>1 or bill_cust_count_last=1) and user_status_id=1
and x_cust_count=1 and arrear_all_fee<1
and (z_call_count>1 or bill_cust_count_last=1) then '0' else v_sql end
from TB_EW_M_PAY_CONDIION_bak;
dbms_output.put_line(v_sql);
end sp_ceshi_case_lmx;