I'm not sure about Sybase, I suppose it's the same principle as in SQL
Server. You have to either generate a dynamic query, by building a string
and running it via the execute function, or have a conditional statement to
select one query or another depending on the sort variable passed. The first
option is more flexible the second more efficent. 

-----Original Message-----
From: Sandi Benditt [mailto:[EMAIL PROTECTED]]
Sent: 27 February 2001 19:28
To: CF-Talk
Subject: Stored Procedure Question (Sybase)




We are in the process of moving all our queries to stored procedures, but 
I've run into a problem that maybe someone can help me with.

Take the following query.  If I move it to a stored procedure and try to 
pass the sort variable to it I get an error along the lines of you can't 
use a variable in an order by (I forget the exact wording).

<CFQUERY NAME="detail" DATASOURCE="GVDB">
SELECT
    vaba, np_code, partnum, qty,  fe_usl, asl
FROM
    gvware..mytd_b3f021_parts
WHERE
    asl="#url.asl#" and
    trans_month="#trans_month#"
ORDER BY
   <CFIF IsDefined("SORT")>
     #sort#
   <CFELSE>
     vaba,asl,fe_usl
   </CFIF>
</CFQUERY>

Can anyone help?
--
Sandi Benditt
Sr. Programmer Analyst - Advanced Technologies
DecisionOne
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to