-- dbo.ep_hdcdzapi_GetKusovnik
CREATE PROCEDURE dbo.ep_hdcdzapi_GetKusovnik
    @idDilce INT,
    @mnf NUMERIC(19,6)=0,
    @datum DATETIME=NULL,
    @IDZakazModif int=NULL,
    @MnozstviSeZtratou bit=1,
    @VcetneNulovychKV bit=0,
    @RespekDodatecneProcZtratKV bit=0,
    @ErrMsg NVARCHAR(500)=N'' OUT
AS

-- HD Consulting Strakonice, T. Buzin
-- !! proceduru neupravujte, bude stejne pregenerovana pri startu Windows sluzby HDCDZApi !!

SET NOCOUNT ON


DROP TABLE IF EXISTS #apiKusovnik
CREATE TABLE #apiKusovnik (ID int IDENTITY (1, 1) NOT NULL, IDRodic int NULL, vyssi integer NULL, IDKmenZbozi integer NOT NULL, uroven integer NOT NULL, poradi integer NOT NULL, 
                           IDKVazby integer NULL, mnozstvi numeric(20,6) NOT NULL, prirez numeric(20,6) NULL, 
                           Prime bit NOT NULL, RezijniMat bit NOT NULL, VyraditZKalkulace bit NOT NULL, Strom nvarchar(400) COLLATE database_default NULL, 
                           Davka numeric(19,6) NULL)

BEGIN TRY
 EXEC dbo.hp_generujKusovnik @IDFinal=@idDilce, @MNF=@mnf, @datum=@datum, @Can_raise=0, @getStrom=1, @GetRodic=1, @IDZakazModif=@IDZakazModif, @VcetneNulovychKV=@VcetneNulovychKV,
                             @MnozstviSeZtratou=@MnozstviSeZtratou, @RespekDodatecneProcZtratKV=@RespekDodatecneProcZtratKV
END TRY
BEGIN CATCH
 SET @ErrMsg = ERROR_MESSAGE()
END CATCH

SELECT * FROM #apiKusovnik

