Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 09 Oct 2012 @ 19:32:48 GMT


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


Subj:   Need help with Stored Procedure: SELECT INTO clause
 
From:   David Clough

This works (of course) ...

     SET sG_SqlStringTx = 'SELECT COUNT(*) FROM '||TRIM(sP_ErrorDb)||'.'||TRIM(sP_TableNm)||' WHERE CON_ID = ?';
     --
     PREPARE sG_sql FROM sG_SqlStringTx ;
     --
     OPEN sG_Csr USING sP_ConId;
     --
     FETCH sG_Csr INTO nG_RowCt;
     CLOSE sG_Csr;

but this doesn't ...

     SET sG_SqlStringTx = 'SELECT COUNT(*) FROM '||TRIM(sP_ErrorDb)||'.'||TRIM(sP_TableNm)||' WHERE CON_ID = ?';
     --
     PREPARE sG_sql FROM sG_SqlStringTx ;
     --
     SET sL_RunCsr = 'OPEN sG_Csr USING sP_ConId;';
     EXECUTE IMMEDIATE sL_RunCsr;
     --
     FETCH sG_Csr INTO nG_RowCt;
     CLOSE sG_Csr;

Any ideas why, guys ?

The only difference is that in the second example I'm trying to dynamically build up the number of USING parameters I need.

The code for the second example compile and doesn't fail when run, it just doesn't bring a value back in nG_RowCt

If this would work then it would then be possible to have one OPEN Cursor Statement, with the number of Using parameters defined by how many filters are being passed through the Procedural interface.

Does that make sense ?


Regards

David Clough
Senior BI Database Designer
BI Competency Centre



     
  <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