Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 20 Jun 2012 @ 12:42:59 GMT


     
  <Prev Next>  
<<First
<Prev
Next>
Last>>
 


Subj:   Cursor In a Procedure - Compilation error
 
From:   Anomy Anom

<-- Anonymously Posted: Wednesday, June 20, 2012 18:31 -->

Hi ,

When I am trying to compile the below mentioned procedure in TD 13.10 environment, I am getting the following error. Referring to undefined alias 'TEST_VALUE_1'

     REPLACE PROCEDURE DB_1.TEST_PROC
     (
         IN INPUT_1   INTEGER,
         IN INPUT_2   INTEGER
     )
     BEGIN
           DECLARE lv_DateToStart   VARCHAR(100);

           FOR TEMPTABLE as FAST_FORWARD CURSOR FOR
                           SELECT SUBSTR(CAST(ALIAS1.COLUMN_TEST AS VARCHAR(8)),0,7) AS TEST_VALUE_1

                           FROM DB_1.TABLE_1 AS ALIAS1

                           INNER JOIN DB_1.TABLE_2 AS TPROD
                           ON ALIAS1.PRODUCTID = TPROD.PRODUCTID

                           INNER JOIN DB_1.TABLE_3 PRODTYPE
                           ON TPROD.COLUMN_4 = PRODTYPE.COLUMN_4

                           WHERE ALIAS1.COLUMN_TEST >= INPUT_1
                           AND ALIAS1.COLUMN_TEST < INPUT_2

                           GROUP BY TEST_VALUE_1
                           ORDER BY TEST_VALUE_1
           DO
                           SET lv_DateToStart = TEMPTABLE.TEST_VALUE_1 ;
           END FOR ;
     END ;

The individual SELECT query runs fine but it errors out while compilation.

Kindly let me know in case I am missing anything.


Thanks in advance



     
  <Prev Next>  
<<First
<Prev
Next>
Last>>
 
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023