2016-05-24 14 views
-1

私はBIRTのDataSetで使用しようとしている動的SQL stmtを持っています(私の英語はフランス語です)。BIRTはデータセットを作成できません。このレポートの解決策は見つかりませんでした。ストアドプロシージャを使用することにしましたが、プロシージャをbirtでコールしようとすると、結果は得られません。誰かが動的な列を使って結果オブジェクトを取得するのを手伝ってもらえますか?このため申し訳ありませんストアドプロシージャのピボットを使用する方法

SET ANSI_NULLS ON 
GO 
SET QUOTED_IDENTIFIER ON 
GO 
SET NOCOUNT ON 
GO 
-- ============================================= 
-- Author:  Reda 
-- Create date: 24/05/2016 
-- Description: Retourne des données test 
-- ============================================= 

CREATE PROCEDURE NomP 


AS 
BEGIN 
    -- SET NOCOUNT ON added to prevent extra result sets from 
    -- interfering with SELECT statements. 
    SET NOCOUNT ON; 

END 
GO 
DECLARE @sqlCommand varchar(MAX) 
DECLARE @ListeAffaires TABLE(Nom_APPEL nvarchar(MAX)) 

    INSERT INTO @ListeAffaires(Nom_APPEL) 
     SELECT DISTINCT AF_NOMAPPEL FROM F_AFFAIRES INNER JOIN T_P_SOCIETE ON AF_CODE_SOCIETE = SOC_CODE 
     WHERE SOC_CODE = 'RUS01' 

declare @Affaires NVARCHAR(MAX) 

SET @Affaires = STUFF(
      (
       SELECT distinct ',ISNULL(' + QUOTENAME(AF_NOMAPPEL) + ', ''0'') ' + QUOTENAME(AF_NOMAPPEL) 
       FROM F_AFFAIRES INNER JOIN T_P_SOCIETE ON AF_CODE_SOCIETE = SOC_CODE 
           INNER JOIN VUE_VALORISATION_TEMPS_PASSES ON VTPS_CODE_AFFAIRE = AF_CODE_AFFAIRE 
        WHERE SOC_CODE = 'RUS01' AND VTPS_date_FICHE >= '02/11/2015' 
       FOR XML PATH(''), TYPE 
      ).value('.', 'NVARCHAR(MAX)') 
     ,1,1,'') 

declare @Affairess NVARCHAR(MAX) 
SET @Affairess = '' 
SELECT @Affairess = @Affairess +'['+ Nom_APPEL + '],' FROM @ListeAffaires 
SET @Affairess = LEFT (@Affairess, LEN(@Affairess) - 1) 


SET @sqlCommand = 'DECLARE @SYNTHESETEMPS TABLE ( VTPS_CODE_COLLAB varchar(250) 
            , VTPS_NOM_COLLAB varchar(250) 
            , VTPS_PRENOM_COLLAB varchar(250) 
            , TSRV_LIBELLE varchar(250) 
            , VTPS_COL_ALPHANUM01 varchar(10) 
            , AF_NOMAPPEL NVARCHAR(MAX) 
            , VTPS_DUREE float(24) 
            ) 

    INSERT INTO @SYNTHESETEMPS (
           VTPS_CODE_COLLAB 
          , VTPS_NOM_COLLAB 
          , VTPS_PRENOM_COLLAB 
          , TSRV_LIBELLE 
          , VTPS_COL_ALPHANUM01 
          , AF_NOMAPPEL 
          , VTPS_DUREE 
           ) 
    SELECT VTPS_CODE_COLLAB 
      , VTPS_NOM_COLLAB 
      , VTPS_PRENOM_COLLAB 
      , TSRV_LIBELLE 
      , VTPS_COL_ALPHANUM01 
      , AF_NOMAPPEL 
     , VTPS_DUREE 
FROM VUE_VALORISATION_TEMPS_PASSES 
INNER JOIN F_P_COLLABORATEUR ON VTPS_CODE_COLLAB = CLB_CODE 
INNER JOIN F_AFFAIRES ON VTPS_CODE_AFFAIRE = AF_CODE_AFFAIRE 
INNER JOIN T_COL_SERVICE ON CLB_TSRV_IDENT = TSRV_IDENT 
INNER JOIN T_P_SOCIETE ON AF_CODE_SOCIETE = SOC_CODE 
WHERE SOC_CODE = ''RUS01'' AND VTPS_date_FICHE >= ''02/11/2015'' 
    SELECT VTPS_NOM_COLLAB +'' '' + VTPS_PRENOM_COLLAB AS "Remaining hours" 
      , TSRV_LIBELLE AS "Service" 
      , VTPS_COL_ALPHANUM01 AS "Categories" 
      ,'+ @Affaires +' 
FROM @SYNTHESETEMPS 
    PIVOT (SUM(VTPS_DUREE) 
    FOR 
     AF_NOMAPPEL IN ('[email protected]+')) PVT ' 
EXEC(@sqlCommand) 



EXEC NomP; 
` 
+0

注意を払っていませんか? –

答えて

0

ストアドプロシージャのあなたの定義は、それが起動する前であってもENDになぜ、私は `

CREATE PROCEDURE NomP 
AS 
BEGIN 
    -- SET NOCOUNT ON added to prevent extra result sets from 
    -- interfering with SELECT statements. 
    SET NOCOUNT ON; 

    DECLARE @sqlCommand varchar(MAX) 

DECLARE @ListeAffaires TABLE(Nom_APPEL nvarchar(MAX)) 

    INSERT INTO @ListeAffaires(Nom_APPEL) 
     SELECT DISTINCT AF_NOMAPPEL FROM F_AFFAIRES INNER JOIN T_P_SOCIETE ON AF_CODE_SOCIETE = SOC_CODE 
     WHERE SOC_CODE = 'RUS01' 

declare @Affaires NVARCHAR(MAX) 

SET @Affaires = STUFF(
      (
       SELECT distinct ',ISNULL(' + QUOTENAME(AF_NOMAPPEL) + ', ''0'') ' + QUOTENAME(AF_NOMAPPEL) 
       FROM F_AFFAIRES INNER JOIN T_P_SOCIETE ON AF_CODE_SOCIETE = SOC_CODE 
           INNER JOIN VUE_VALORISATION_TEMPS_PASSES ON VTPS_CODE_AFFAIRE = AF_CODE_AFFAIRE 
        WHERE SOC_CODE = 'RUS01' AND VTPS_date_FICHE >= '02/11/2015' 
       FOR XML PATH(''), TYPE 
      ).value('.', 'NVARCHAR(MAX)') 
     ,1,1,'') 

declare @Affairess NVARCHAR(MAX) 
SET @Affairess = '' 
SELECT @Affairess = @Affairess +'['+ Nom_APPEL + '],' FROM @ListeAffaires 
SET @Affairess = LEFT (@Affairess, LEN(@Affairess) - 1) 


SET @sqlCommand = 'DECLARE @SYNTHESETEMPS TABLE ( VTPS_CODE_COLLAB varchar(250) 
            , VTPS_NOM_COLLAB varchar(250) 
            , VTPS_PRENOM_COLLAB varchar(250) 
            , TSRV_LIBELLE varchar(250) 
            , VTPS_COL_ALPHANUM01 varchar(10) 
            , AF_NOMAPPEL NVARCHAR(MAX) 
            , VTPS_DUREE float(24) 
            ) 

    INSERT INTO @SYNTHESETEMPS (
           VTPS_CODE_COLLAB 
          , VTPS_NOM_COLLAB 
          , VTPS_PRENOM_COLLAB 
          , TSRV_LIBELLE 
          , VTPS_COL_ALPHANUM01 
          , AF_NOMAPPEL 
          , VTPS_DUREE 
           ) 
    SELECT VTPS_CODE_COLLAB 
      , VTPS_NOM_COLLAB 
      , VTPS_PRENOM_COLLAB 
      , TSRV_LIBELLE 
      , VTPS_COL_ALPHANUM01 
      , AF_NOMAPPEL 
     , VTPS_DUREE 
FROM VUE_VALORISATION_TEMPS_PASSES 
INNER JOIN F_P_COLLABORATEUR ON VTPS_CODE_COLLAB = CLB_CODE 
INNER JOIN F_AFFAIRES ON VTPS_CODE_AFFAIRE = AF_CODE_AFFAIRE 
INNER JOIN T_COL_SERVICE ON CLB_TSRV_IDENT = TSRV_IDENT 
INNER JOIN T_P_SOCIETE ON AF_CODE_SOCIETE = SOC_CODE 
WHERE SOC_CODE = ''RUS01'' AND VTPS_date_FICHE >= ''02/11/2015'' 
    SELECT VTPS_NOM_COLLAB +'' '' + VTPS_PRENOM_COLLAB AS "Remaining hours" 
      , TSRV_LIBELLE AS "Service" 
      , VTPS_COL_ALPHANUM01 AS "Categories" 
      ,'+ @Affaires +' 
FROM @SYNTHESETEMPS 
    PIVOT (SUM(VTPS_DUREE) 
    FOR 
     AF_NOMAPPEL IN ('[email protected]+')) PVT ' 
EXEC(@sqlCommand) 


END 
関連する問題