
insert into pophelp(field_name,mod_name,sql_str,msg_title,width,height,chg_date,chg_user,chg_term,dist_opt,sql_input,default_col,help_option,auto_fill_len)
values('CONTACT_PERS','W_ENTITY_CONTACT','select ''Enter minimum three characters of Customer Name'' as contact_person, '''' as contact_person_name from dual where ''?'' is null or length(''?'') < 3 union all select emp_code as contact_person ,emp_fname||'' ''||emp_mname||'' ''||emp_lname  as contact_person_name from employee WHERE (emp_code NOT IN (select E.EMP_CODE from EMPLOYEE E where E.RELIEVE_DATE is null start with E.EMP_CODE = ''?'' connect by prior E.EMP_CODE = E.REPORT_TO) and RELIEVE_DATE is null) and (emp_code LIKE UPPER(''%?%'') OR trim(emp_fname)||'' ''||trim(emp_mname)||'' ''||trim(emp_lname) LIKE UPPER(''%?%'')) and ''?''=''E'' and length(''?'') >= 3','Contact Person',0,0,sysdate,'PRACHI','PRACHI',0,':contact_pers,:contact_pers,:entity_code,:contact_pers,:contact_pers,:entity_type,:contact_pers',0,2,3);

UPDATE POPHELP SET SQL_STR='select ''Enter minimum three characters of Customer Name'' as entity_code, '''' as ent_descr from dual where ''?'' is null or length(''?'') < 3 union select sc_code as entity_code,CONCAT(CONCAT(FIRST_NAME,MIDDLE_NAME),LAST_NAME)  as ent_descr from strg_customer WHERE (status=''U'' or status=''A'') and ((trim(FIRST_NAME) ||'' ''||trim(MIDDLE_NAME) ||'' ''||TRIM(LAST_NAME)) LIKE UPPER(''%?%'') OR SC_CODE LIKE UPPER(''%?%'')) and ''?''=''C'' and length(''?'') >= 3 UNION ALL select SUPP_CODE as entity_code,SUPP_NAME  as ent_descr from SUPPLIER WHERE  (SUPP_NAME LIKE UPPER(''%?%'') OR SUPP_CODE LIKE UPPER(''%?%'')) and ''?''=''S'' and length(''?'') >= 3 UNION ALL select TRAN_CODE as entity_code,TRAN_NAME  as ent_descr from transporter WHERE  (TRAN_NAME LIKE UPPER(''%?%'') OR TRAN_CODE LIKE UPPER(''%?%'')) and ''?''=''T'' and length(''?'') >= 3 UNION ALL select sales_pers as entity_code,SP_NAME  as ent_descr from sales_pers WHERE  (sales_pers LIKE UPPER(''%?%'') OR SP_NAME LIKE UPPER(''%?%'')) and ''?''=''R'' and length(''?'') >= 3 UNION ALL select emp_code as entity_code,emp_fname||'' ''||emp_mname||'' ''||emp_lname  as ent_descr from employee WHERE  (emp_code LIKE UPPER(''%?%'') OR trim(emp_fname)||'' ''||trim(emp_mname)||'' ''||trim(emp_lname) LIKE UPPER(''%?%'')) and ''?''=''E'' and length(''?'') >= 3',SQL_INPUT=':entity_code,:entity_code,:entity_code,:entity_code,:entity_type,:entity_code,:entity_code,:entity_code,:entity_type,:entity_code,:entity_code,:entity_code,:entity_type,:entity_code,:entity_code,:entity_code,:entity_type,:entity_code,:entity_code,:entity_code,:entity_type,:entity_code' where mod_name='W_ENTITY_CONTACT' AND field_name='ENTITY_CODE';


INSERT INTO GENMST(FLD_NAME,MOD_NAME,DESCR,ERROR_CD,BLANK_OPT,FLD_TYPE,FLD_MIN,FLD_MAX,VAL_TYPE,CHG_DATE,CHG_USER,CHG_TERM,SQL_INPUT,FLD_WIDTH,OBJ_NAME,FORM_NO,ACTION,TRAN_ID)
VALUES('CONTACT_PERS','W_ENTITY_CONTACT','Validation','VECPEMP','N','C','select (case when (length(trim(?)) > 0 and (trim(?)=''E'')) then (select count(*) from employee WHERE (emp_code NOT IN (select E.EMP_CODE from EMPLOYEE E where E.RELIEVE_DATE is null start with E.EMP_CODE =? connect by prior E.EMP_CODE = E.REPORT_TO) and RELIEVE_DATE is null) and emp_code=?) else 0 end)as count from dual',1,'Q',sysdate,'BASE','BASE',':0.contact_pers,:0.entity_type,:0.entity_code,:0.contact_pers',0,'entity_contact',1,'EDIT','00000000000000000670');

insert into messages(msg_no,msg_str,msg_descr,msg_type,msg_opt,chg_user,chg_term) 
values('VECPEMP','Contact Person Invalid','contact person not exist or present in own hierarchy','E','Y','BASE','BASE');

insert into messages(msg_no,msg_str,msg_descr,msg_type,msg_opt,chg_user,chg_term) 
values('VLECUIP','Invalid Column Value','Entity Code and User Id should be same','E','Y','BASE','BASE');

Insert into OBJ_ITEMCHANGE (OBJ_NAME,FORM_NO,FIELD_NAME,MANDATORY) values ('entity_contact','1','contact_pers',null);

