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,45 +348,31 @@ values ('NT','P91','M','U','POD CREDIT POLICY','POD CREDIT POLICY',sysdate,'BASE
--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
TYPE InvCurTyp IS REF CURSOR;
inv_cur InvCurTyp;
cnumber number;
inv_type varchar2(3);
ls_string varchar2(600);
ls_instring varchar2(600);
--type inv_type_arr is varray(3) of varchar2(10);
ls_sql varchar2(2000);
li_pos number;
inv_type_list varchar2(600);
pod_cnt number;
ls_invoiceid char(10);
ls_sql_stmt varchar2(2000);
ls_sql_stmt varchar2(3000);
BEGIN
cnumber := 0;
select var_value into ls_string from disparm where var_name = 'POD_INV_TYPE';
ls_sql_stmt := 'select invoice_id from invoice where cust_code__bil = :p and
site_code = :s lck
and inv_type in (';
select var_value into inv_type_list from disparm where var_name = 'POD_INV_TYPE' and prd_code = '999999';
li_pos := instr(ls_string,',');
if li_pos = 0 then
select replace(inv_type_list,',',''',''') into inv_type_list FROM DUAL;
ls_sql_stmt := ls_sql_stmt || '''' ||ls_string || ''')';
inv_type_list := '''' || inv_type_list || '''';
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) || ')';
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';
end if;
--dbms_output.put_line('sql - ' || ls_sql_stmt);
begin
......@@ -397,8 +383,7 @@ site_code = :s lck
LOOP
FETCH inv_cur INTO ls_invoiceid;
EXIT WHEN inv_cur%NOTFOUND;
select count(1) into pod_cnt from spl_sales_por_hdr where invoice_id =
ls_invoiceid;
select count(1) into pod_cnt from spl_sales_por_hdr where invoice_id = ls_invoiceid;
if pod_cnt = 0 then
cnumber := 1;
......
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