none
Fetch Next and variable: error: Must declare the scalar variable "@R1_Werks". RRS feed

  • Domanda

  • Hi to all.

    I have a strange problem with Sql Server 2005. I use this code:

     

    --..........
    --..........
    
    Declare @R1_WERKS		 Char (04)
    		 , @R1_KSTAR		 Char (15)
    		 , @R1_MATNR		 Char (18)
    		 , @R1_LGORT		 Char (04)
    		 , @R1_WERKS_R		 Char (04)
    		 , @R1_MATNR_R		 Char (18)
    		 , @R1_LGORT_R		 Char (04)
    		 , @R1_CHARG		 Char (10)
    		 , @R2_WERKS		 Char (04)
    		 , @R2_KSTAR		 Char (15)
    		 , @R2_MATNR		 Char (18)
    		 , @R2_LGORT		 Char (04)
    		 , @R2_WERKS_R		 Char (04)
    		 , @R2_MATNR_R		 Char (18)
    		 , @R2_LGORT_R		 Char (04)
    		 , @R2_CHARG		 Char (10)
    
    --..........
    --..........
    
    Open	Cursor_Itself
     Fetch Next From Cursor_Itself
    			 Into @R1_Werks  , @R1_Matnr  , @R1_Lgort
    				, @R1_Werks_r , @R1_Matnr_r , @R1_Lgort_r , @R1_Charg
    

     

    I receive the message Must declare the scalar variable "@R1_Werks" for all call of command fetch next e for any variable.

    I don't understand: variables are declared and the same code in an other Sql Server (this is a migration from an other Sql Server 2005) work fine.

    Any ideas?

    Thank's to all!!

    martedì 24 maggio 2011 08:34

Risposte

Tutte le risposte

  • I declare the cursors in this way:

    Declare Cursor_Itself	CURSOR Fast_Forward FOR
     Select Werks
    	  , Matnr
    	  , Lgort
    	  , Werks_r
    	  , Matnr_r
    	  , Lgort_r
    	  , Charg
    	From #TMP_PROD_TRASF
    	Group by Werks, Matnr, Lgort , Werks_r, Matnr_r , Lgort_r , Charg
    	Order By Werks, Werks_r, Matnr, Matnr_r , Lgort , Lgort_r
    

    martedì 24 maggio 2011 08:47
  • We find the problem: the database are case sensitive!

    I close the post.

    martedì 24 maggio 2011 10:50