
             WITH cte AS (
                SELECT
                    cast('120101127039862' as bigint) AS res,
                    CASE WHEN NULL IS NOT NULL THEN NULL ELSE (SELECT morbus_id FROM v_evn WHERE evn_id = '120101127039775' LIMIT 1) END AS morbus_id
            )
            select
            	EvnUslugaCommon_id as "EvnUslugaCommon_id",
                Error_Code as "Error_Code",
                Error_Message as "Error_Msg"
            from dbo.p_EvnUslugaCommon_upd(
            	EvnUslugaCommon_id := (select res from cte),
                EvnUslugaCommon_pid := '120101127039775',
                Lpu_id := '3311009',
                Server_id := 0,
                PersonEvn_id := '120101009710138',
                EvnUslugaCommon_setDT := '2022-02-21 15:23',
                EvnUslugaCommon_disDT := '2022-02-21 15:23',
                PayType_id := '120101000000023',
                Usluga_id := NULL,
                UslugaComplex_id := '120101000006846',
                MedSpecOms_id := NULL,
                LpuSectionProfile_id := '120101000000222',
                MedPersonal_id := '120101000011380',
                MedStaffFact_id := '120101000110044',
                MedStaffFact_sid := NULL,
                UslugaPlace_id := '1',
                Lpu_uid := NULL,
                LpuSection_uid := '120101000005609',
                Org_uid := NULL,
                EvnUslugaCommon_Kolvo := 1,
                Morbus_id := (select morbus_id from cte),
                EvnUslugaCommon_CoeffTariff := NULL,
                EvnUslugaCommon_IsModern := NULL,
                MesOperType_id := NULL,
                UslugaComplexTariff_id := NULL,
                DiagSetClass_id := NULL,
                Diag_id := NULL,
                EvnUslugaCommon_Price := NULL,
                EvnUslugaCommon_Summa := NULL,
                EvnPrescr_id := NULL,
                EvnUslugaCommon_IsVizitCode := NULL,
                EvnUslugaCommon_IsMinusUsluga := 1,
                EvnDirection_id := NULL,
                UslugaExecutionType_id := NULL,
                UslugaExecutionReason_id := NULL,
                pmUser_id := '392536762958');
        
