Commit c7895ea7 authored by ssurve's avatar ssurve

function fn_pod_chk code changed.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93482 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c8661de2
...@@ -348,71 +348,56 @@ values ('NT','P91','M','U','POD CREDIT POLICY','POD CREDIT POLICY',sysdate,'BASE ...@@ -348,71 +348,56 @@ values ('NT','P91','M','U','POD CREDIT POLICY','POD CREDIT POLICY',sysdate,'BASE
--Function --Function
CREATE OR REPLACE Function fn_pod_chk ( ls_custCodeBill in char, ls_siteCode in char) create or replace
Function fn_pod_chk ( ls_custCodeBill in char, ls_siteCode in char)
RETURN number IS RETURN number IS
TYPE InvCurTyp IS REF CURSOR; TYPE InvCurTyp IS REF CURSOR;
inv_cur InvCurTyp; inv_cur InvCurTyp;
cnumber number; cnumber number;
inv_type varchar2(3); inv_type varchar2(3);
ls_string varchar2(600); inv_type_list varchar2(600);
ls_instring varchar2(600); pod_cnt number;
--type inv_type_arr is varray(3) of varchar2(10); ls_invoiceid char(10);
ls_sql varchar2(2000); ls_sql_stmt varchar2(3000);
li_pos number;
pod_cnt number;
ls_invoiceid char(10);
ls_sql_stmt varchar2(2000);
BEGIN BEGIN
cnumber := 0; cnumber := 0;
select var_value into ls_string from disparm where var_name = 'POD_INV_TYPE'; select var_value into inv_type_list from disparm where var_name = 'POD_INV_TYPE' and prd_code = '999999';
ls_sql_stmt := 'select invoice_id from invoice where cust_code__bil = :p and
site_code = :s lck select replace(inv_type_list,',',''',''') into inv_type_list FROM DUAL;
and inv_type in (';
inv_type_list := '''' || inv_type_list || '''';
li_pos := instr(ls_string,',');
if li_pos = 0 then ls_sql_stmt := 'select invoice_id from invoice where cust_code__bil = :ls_custCodeBill and site_code = :ls_siteCode and inv_type in ('||inv_type_list||') and sysdate - conf_date > 29';
ls_sql_stmt := ls_sql_stmt || '''' ||ls_string || ''')'; --dbms_output.put_line('sql - ' || ls_sql_stmt);
else
while li_pos > 0 loop
ls_sql_stmt := ls_sql_stmt || '''' || substr(ls_string,1,li_pos -1) || ''',';
ls_string := substr(ls_string, length(ls_string) - (li_pos + length(',') - 1));
li_pos := instr(ls_string,',');
end loop;
ls_sql_stmt := substr(ls_sql_stmt,1, length(ls_sql_stmt) - 1) || ')';
end if;
begin begin
-- cursor for multiple invoices against passed cust_code -- cursor for multiple invoices against passed cust_code
OPEN inv_cur FOR ls_sql_stmt USING ls_custCodeBill, ls_siteCode; OPEN inv_cur FOR ls_sql_stmt USING ls_custCodeBill, ls_siteCode;
-- Fetch rows from result set one at a time: -- Fetch rows from result set one at a time:
LOOP LOOP
FETCH inv_cur INTO ls_invoiceid; FETCH inv_cur INTO ls_invoiceid;
EXIT WHEN inv_cur%NOTFOUND; EXIT WHEN inv_cur%NOTFOUND;
select count(1) into pod_cnt from spl_sales_por_hdr where invoice_id = select count(1) into pod_cnt from spl_sales_por_hdr where invoice_id = ls_invoiceid;
ls_invoiceid;
if pod_cnt = 0 then
if pod_cnt = 0 then cnumber := 1;
cnumber := 1; exit;
exit; else
else cnumber := 0;
cnumber := 0; end if;
end if; END LOOP;
END LOOP;
-- Close cursor:
-- Close cursor: CLOSE inv_cur;
CLOSE inv_cur; end;
end;
return cnumber;
return cnumber;
END; END;
--end function --end function
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment