DBAsupport.com Forums - Powered by vBulletin
Results 1 to 10 of 15

Thread: Group By in Dynamic SQL

Threaded View

  1. #4
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Code:
    SQL_STMT:='SELECT '||AGGREGATION_TYPE_VAR||'('||COLUMN_NAME_VAR||'),'||AGGR_COLUMN_VAR||' FROM '||TABLE_NAME_VAR||
    ' WHERE '||COLUMN_NAME_VAR||'=10 GROUP BY '||':PAR1';
    EXECUTE IMMEDIATE SQL_STMT INTO CURRENT_EXET_NUMBER USING AGGR_COLUMN_VAR;
    You can't use a bind variable there! I think those last two lines would need to be:
    Code:
    ' WHERE '||COLUMN_NAME_VAR||'=10 GROUP BY '||AGGR_COLUMN_VAR;
    EXECUTE IMMEDIATE SQL_STMT INTO CURRENT_EXET_NUMBER;
    BTW what happens when it returns more than one row?
    Last edited by DaPi; 04-10-2006 at 09:43 AM.
    "The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width