Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Sat, 24 Mar 2007 @ 09:29:16 GMT


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


Subj:   Re: Can fields be passed as param for ORDER BY?
 
From:   McCall, Glenn David

I don't believe you can do this the way that you are trying to do it.

However, since you are using .net, you can submit dynamic SQL. This is SQL that is varied based upon user input.

I don't know what language you are using, so here is a 'C' example;

     Char sql [2000];
     Char orderby[100];
     strcpy (sql, "select * from some_table ");
     /* Code to determine the correct order by clause */
     strcat (sql, orderby);

Here is a basic equivalent:

     Dim sql As String
     Dim orderby As String

     sql = "select * from some_table "
     ' logic to determine correct order by clase
     orderby = "order by 1,2,3"
     sql = sql + orderby

In either case, sql has the sql with the dynamic order by clause which you can then submit to Teradata.

Another possibility is to use a Stored Procedure (which is different to a macro). A stored procedure runs on Teradata and can do essentially the same thing as the above. Although in the SP, you must do something with the result set, it doesn't automatically get returned to the client application, but that is OK, you can process it in the SP and just return the end result to the client app. It all depends upon what you are trying to do.


I hope this helps

Glenn Mc



     
  <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