
		
	DO $$
	DECLARE
		v_params tmp$params%rowtype;
	BEGIN
		select * from tmp$params into v_params;
		select FRLLO_id into v_params.id from dbo.FRLLO where Person_id = v_params.personId AND FRLLO_RegNum = v_params.regNum;
		if v_params.id is null then
			SELECT
				FRLLO_id, case when nullif(Error_code, '0') is null then 0 else 1 end, Error_code || ':' || Error_Message
			into v_params.id, v_params.errorCode, v_params.errorMessage
			from p_FRLLO_ins(
				Person_id => v_params.personId,
				FRLLO_RegNum => v_params.regNum,
				pmUser_id => v_params.pmUserId
			) i;
		end if;
		update tmp$params set id = v_params.id, errorCode=v_params.errorCode, errorMessage=v_params.errorMessage;
	END $$
