在PLsql里Test包里的FUNCTION可以正常执行,
当在C#前台调用时返回值正确但是数据未添加到表里
--获取生成托标签 FUNCTION get_tackle_num(p_frist IN VARCHAR2, p_num IN NUMBER, p_year_and_m IN VARCHAR2) RETURN VARCHAR2 IS lv_code VARCHAR2(20); lv_code2 VARCHAR2(20); lv_codelist VARCHAR2(20000); lv_maxnum VARCHAR2(20); lv_num number; lv_workshop VARCHAR2(20); lv_org VARCHAR2(20); --ln_message_id number := ljmes.system_api_pkg.success; lr_rows longimes.LJ_MES_QP_TACKLE%ROWTYPE; BEGIN --获取车间,组织Id lv_workshop := longimes.lj_mes_qp_public_pck.get_workshop_one; lv_org := get_organization_id; --获取托板编号 lv_code := p_frist || lv_workshop || p_year_and_m; --获取流水号 select Max(substr(t.tackle_num, -4)) into lv_maxnum from longimes.lj_mes_qp_tackle t where substr(t.tackle_num, 0, 6) = lv_code; --获取流水号 IF lv_maxnum is null THEN lv_num := 0; ELSE lv_num := to_number(lv_maxnum); END IF; --是否超出范围 IF lv_num + p_num > 9999 THEN RETURN 'E@错误@流水号超出最大范围'; END IF; --公共部分 lr_rows.creation_date := SYSDATE; lr_rows.created_by := ljmes.system_api_pkg.get_user_id; lr_rows.last_update_date := SYSDATE; lr_rows.last_updated_by := ljmes.system_api_pkg.get_user_id; lr_rows.last_update_login := ljmes.system_api_pkg.get_client_session_id; --生成标签号并存到表里 FOR i IN 1 .. p_num LOOP lv_code2 := lv_code || lpad(to_char(lv_num + i), 4, 0); lv_codelist := lv_codelist || lv_code2 || ','; --保存 lr_rows.k_id := longimes.lj_mes_qp_tackle_s.nextval; lr_rows.organization_id := lv_org; lr_rows.tackle_num := lv_code2; lr_rows.status := 'VALID'; lr_rows.tackle_name := '托'; INSERT INTO longimes.LJ_MES_QP_TACKLE VALUES lr_rows; END LOOP; RETURN lv_codelist; END;
function里最后insert后加上一句commit;
知道了,但是为什么在这个外面加一个get_tackle_num_for_ui调用get_tackle_num
程序调用get_tackle_num_for_ui就可以了
@李zp: 因为get_tackle_num_for_ui中有commit;