====== pears.NetOwnerCompanyEdit ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== create procedure "pears"."NetOwnerCompanyEdit"( in "pWebUserID" char(20),in "pObjID" char(20),in "pParentObject" char(20),in "pCompany_Name" char(60),in "pAddress_Line_1" char(40),in "pAddress_Line_2" char(40),in "pAddress_Line_3" char(40),in "pTown" char(30),in "pCounty" char(30),in "pCountry" char(30),in "pPostcode" char(20),in "pPhone" char(100),in "pFax" char(100),in "pWeb_Site" char(100),in "pOldCompany_Name" char(60),in "pOldAddress_Line_1" char(40),in "pOldAddress_Line_2" char(40),in "pOldAddress_Line_3" char(40),in "pOldTown" char(30),in "pOldCounty" char(30),in "pOldCountry" char(30),in "pOldPostcode" char(20),in "pOldPhone" char(100),in "pOldFax" char(100),in "pOldWeb_Site" char(100) ) result( "pResult" char(250) ) begin declare "CompID" char(20); declare "ssql" char(255); declare "divid" char(20); set "ssql" = ''; set "divid" = (select first "staff"."divisionid" from "iqxnetuser" key join "staff" where "iqxnetuser"."iqxnetuserid" = "pwebuserid"); if "divid" is null then select '99:~Permission denied'; return end if; if "pCompany_Name" = '' then select '101:~Please ensure there is a Company Name'; return end if; if "pObjID" = '' then set "CompID" = "uniquekey"("pCompany_Name"); insert into "company"( "companyid","name","keyname","clientcode","divisionid" ) values( "CompID","pCompany_Name","ucase"("pCompany_Name"),"pParentObject","divid" ) else set "CompID" = "pObjID"; if "pCompany_Name" <> "pOldCompany_Name" then set "ssql" = "ssql"+',name=pCompany_Name,keyname = ucase(pCompany_Name)' end if end if; if "pAddress_Line_1" <> "pOldAddress_Line_1" then set "ssql" = "ssql"+',addr1=pAddress_Line_1' end if; if "pAddress_Line_2" <> "pOldAddress_Line_2" then set "ssql" = "ssql"+',addr2=pAddress_Line_2' end if; if "pAddress_Line_3" <> "pOldAddress_Line_3" then set "ssql" = "ssql"+',addr3=pAddress_Line_3' end if; if "pTown" <> "pOldTown" then set "ssql" = "ssql"+',town=pTown' end if; if "pCounty" <> "pOldCounty" then set "ssql" = "ssql"+',county=pCounty' end if; if "pCountry" <> "pOldCountry" then set "ssql" = "ssql"+',country=pCountry' end if; if "pPostcode" <> "pOldPostcode" then set "ssql" = "ssql"+',Postcode=pPostcode' end if; if "ssql" > '' then execute immediate 'update company set '+"stuff"("ssql",1,1,'')+' where companyid = CompID' end if; if "pPhone" <> "pOldPhone" then call "SetPhone"('C','Telephone',"CompID","pPhone") end if; if "pFax" <> "pOldFax" then call "SetPhone"('C','Fax',"CompID","pFax") end if; if "pWeb_Site" <> "pOldWeb_Site" then call "SetPhone"('C','Web Site',"CompID","pWeb_Site") end if; select "string"('0:',"CompID",'#',"pParentObject",'~Success') end go COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetOwnerCompanyEdit" IS {create PROCEDURE pears."NetOwnerCompanyEdit"( in "pWebUserID" char(20),in "pObjID" char(20),in "pParentObject" char(20),in "pCompany_Name" char(60),in "pAddress_Line_1" char(40),in "pAddress_Line_2" char(40),in "pAddress_Line_3" char(40),in "pTown" char(30),in "pCounty" char(30),in "pCountry" char(30),in "pPostcode" char(20),in "pPhone" char(100),in "pFax" char(100),in "pWeb_Site" char(100),in "pOldCompany_Name" char(60),in "pOldAddress_Line_1" char(40),in "pOldAddress_Line_2" char(40),in "pOldAddress_Line_3" char(40),in "pOldTown" char(30),in "pOldCounty" char(30),in "pOldCountry" char(30),in "pOldPostcode" char(20),in "pOldPhone" char(100),in "pOldFax" char(100),in "pOldWeb_Site" char(100) ) result( "pResult" char(250) ) begin declare "CompID" char(20); declare "ssql" char(255); declare "divid" char(20); set "ssql" = ''; set "divid" = (select first "staff"."divisionid" from "iqxnetuser" key join "staff" where "iqxnetuser"."iqxnetuserid" = "pwebuserid"); if "divid" is null then select '99:~Permission denied'; return end if; if "pCompany_Name" = '' then select '101:~Please ensure there is a Company Name'; return end if; if "pObjID" = '' then set "CompID" = "uniquekey"("pCompany_Name"); insert into "company"( "companyid","name","keyname","clientcode","divisionid" ) values( "CompID","pCompany_Name","ucase"("pCompany_Name"),"pParentObject","divid" ) else set "CompID" = "pObjID"; if "pCompany_Name" <> "pOldCompany_Name" then set "ssql" = "ssql"+',name=pCompany_Name,keyname = ucase(pCompany_Name)' end if end if; if "pAddress_Line_1" <> "pOldAddress_Line_1" then set "ssql" = "ssql"+',addr1=pAddress_Line_1' end if; if "pAddress_Line_2" <> "pOldAddress_Line_2" then set "ssql" = "ssql"+',addr2=pAddress_Line_2' end if; if "pAddress_Line_3" <> "pOldAddress_Line_3" then set "ssql" = "ssql"+',addr3=pAddress_Line_3' end if; if "pTown" <> "pOldTown" then set "ssql" = "ssql"+',town=pTown' end if; if "pCounty" <> "pOldCounty" then set "ssql" = "ssql"+',county=pCounty' end if; if "pCountry" <> "pOldCountry" then set "ssql" = "ssql"+',country=pCountry' end if; if "pPostcode" <> "pOldPostcode" then set "ssql" = "ssql"+',Postcode=pPostcode' end if; if "ssql" > '' then execute immediate 'update company set '+"stuff"("ssql",1,1,'')+' where companyid = CompID' end if; if "pPhone" <> "pOldPhone" then call "SetPhone"('C','Telephone',"CompID","pPhone") end if; if "pFax" <> "pOldFax" then call "SetPhone"('C','Fax',"CompID","pFax") end if; if "pWeb_Site" <> "pOldWeb_Site" then call "SetPhone"('C','Web Site',"CompID","pWeb_Site") end if; select "string"('0:',"CompID",'#',"pParentObject",'~Success') end }