call user defined sql function via classic asp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • omar999
    New Member
    • Mar 2010
    • 120

    call user defined sql function via classic asp

    hi guys

    I have a user defined sql function in my sql server db called TenPercentDisco unt but not sure how to call it via classic asp?

    iv tried both
    objRS(TenPercen tDiscount("Doub le_Redleaf_Pric e"))
    TenPercentDisco unt(objRS("Doub le_Redleaf_Pric e"))

    but not having any joy? Double_Redleaf_ Price is an integer value and my function code is
    Code:
    CREATE FUNCTION TenPercentDiscount 
    (@InputVals int)
    RETURNS int
    AS
    BEGIN
    declare @convertedVal varchar(30)
    set @convertedVal =  Cast(@InputVals  * 0.9 as int)
    return  @convertedVal 
    end
    please adivse
    omar
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    You can't call it from the asp, you need to use it IN your sql query.
    Code:
    select tenpercentdiscount(redleafprice) as newprice from mytable
    Jared
    Last edited by jhardman; Nov 11 '10, 03:18 PM. Reason: Added code sample

    Comment

    • omar999
      New Member
      • Mar 2010
      • 120

      #3
      hi Jared - thanks for clarifying.

      I shall post this question in the sql section then..

      thanks again
      Omar.

      Comment

      Working...