====== pears.SetPersonWillingness ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."SetPersonWillingness" IS {create function SetPersonWillingness /* Application Maintained Function / Procedure - DO NOT EDIT*/ ( in @PersonID char(20),in @Willingness smallint default null ) returns smallint begin -- return codes: 0 = success, 1 = no such PersonID, 2 = no Willingness record for PersonID, 3 = other error -- call with only PersonID to remove existing Willingness Record begin try if @Willingness is not null then insert into "pears"."PersonWillingness"( "PersonID","Willingness" ) on existing update defaults off values ( @PersonID,@Willingness ) else delete from "pears"."PersonWillingness" where "PersonID" = @PersonID end if; if @@rowcount = 1 then return(0) elseif @Willingness is null and not exists(select "PersonID" from "PersonWillingness" where "PersonID" = @PersonID) and exists(select "PersonID" from "Person" where "PersonID" = @PersonID) then return(2) elseif @Willingness is null and not exists(select "PersonID" from "Person" where "PersonID" = @PersonID) then return(1) else return(3) end if end try begin catch if not exists(select "PersonID" from "Person" where "PersonID" = @PersonID) then return(1) else return(3) end if end catch end }