Home Page for the TeradataForum
 
https:

Archives of the TeradataForum

Message Posted: Fri, 05 Oct 2012 @ 12:25:35 GMT


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


Subj:   Re: Stored Procedure: SELECT INTO clause
 
From:   Dieter Noeth

You didn't show the error message, but i assume it's a syntax error. A variable can't be used for any database/table/column name.

You need a cursor with some dynamic SQL, because you can't use SELECT INTO dynamically:

     DECLARE sqlstr VARCHAR(1000);
     DECLARE c CURSOR FOR s;

     SET SqlStr = 'SELECT COUNT(*) INTO :vClient_ID  FROM ' || vDBName
         || '.CLIENT_TABLE WHERE CLIENT_CODE = ''ABC''';

     PREPARE s FROM SqlStr;
     OPEN c;
     FETCH c INTO vClient_ID;
     CLOSE c;

Dieter



     
  <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: 28 Jun 2020