====== pears.AddPhone ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."AddPhone"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "cpe" char(2),in "ptype" char(25),in "recid" char(20),in "snumber" char(200) )
begin
declare "tpid" char(20);
declare "sid" char(20);
if "trim"("isnull"("ptype",'')) = '' then
return
end if;
if "trim"("isnull"("recid",'')) = '' then
return
end if;
if "trim"("isnull"("snumber",'')) = '' then
return
end if;
if "cpe" = 'E' then
set "cpe" = 'CP'
end if;
set "tpid" = null;
if "cpe" = 'C' then
select "phonetypeid" into "tpid" from "phonetype" where "name" = "ptype" and "company" = 1
else if "cpe" = 'P' then
select "phonetypeid" into "tpid" from "phonetype" where "name" = "ptype" and "applicant" = 1
else if "cpe" = 'CP' then
select "phonetypeid" into "tpid" from "phonetype" where "name" = "ptype" and "contact" = 1
end if
end if end if;
if "tpid" is null then
return
end if;
set "sid" = "uniquekey"('x');
insert into "phone"( "phoneid","phonetypeid","who","whoid","number" ) values( "sid","tpid","cpe","recid","snumber" )
end
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."AddPhone" IS
{create procedure AddPhone
/* Application Maintained Function / Procedure - DO NOT EDIT*/
(in cpe char(2),in ptype char(25),in recid char(20),in snumber char(200))
begin
declare tpid char(20);
declare sid char(20);
if trim(isnull(ptype,'')) = '' then
return
end if;
if trim(isnull(recid,'')) = '' then
return
end if;
if trim(isnull(snumber,'')) = '' then
return
end if;
if cpe = 'E' then
set cpe='CP'
end if;
set tpid=null;
if cpe = 'C' then
select phonetypeid into tpid from phonetype where name = ptype and company = 1
else if cpe = 'P' then
select phonetypeid into tpid from phonetype where name = ptype and applicant = 1
else if cpe = 'CP' then
select phonetypeid into tpid from phonetype where name = ptype and contact = 1
end if
end if
end if;
if tpid is null then
return
end if;
set sid=uniquekey('x');
insert into phone(phoneid,phonetypeid,who,whoid,number) values(sid,tpid,cpe,recid,snumber)
end
}