mysql := 'select unpay_fee '||'into unpayfee ' || ' from acc_bill_' || TO_CHAR(r_gsa.city_id) || 'r_gsa (加上别名,另外你在这里少了空格)where bill_month='||''''||to_char(add_months(SYSDATE,-1),'YYYYMM')||''''||' and acc_id='||r_gsa.acc_id ;我提供另外一个语法给你,你试试: mysql := 'select unpay_fee from acc_bill_' || TO_CHAR(r_gsa.city_id) || ' r_gsa where bill_month='||''''||to_char(add_months(SYSDATE,-1),'YYYYMM')||''''||' and acc_id='||r_gsa.acc_id ;execute immediate mysql into unpayfee ; dbms_output.put_line(mysql);
谢谢nowait,不过正要请教这个问题 mysql若为空怎么办,用execute immediate mysql into unpayfee ;会报取值为空错
mysql := 'select unpay_fee from acc_bill_' || TO_CHAR(r_gsa.city_id) || ' r_gsa where bill_month='||''''||to_char(add_months(SYSDATE,-1),'YYYYMM')||''''||' and acc_id='||r_gsa.acc_id ;execute immediate mysql into unpayfee ;
dbms_output.put_line(mysql);