MSSQL Stored Procedure Problem

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default MSSQL Stored Procedure Problem

    I am trying to pass some variables into a MSSQL stored procedure and for some
    reason it is truncating the last variable. If I move the order of the variables
    in the stored procedure it always drops the last one. I have done this plenty
    of times without problems, but for some reason it is not working with this
    code. Here is what I have, any help would be wonderful.

    CF Code:

    <cfstoredproc datasource="crup" procedure="sp_rate">

    <cfprocparam value="#gs_limits#" dbvarname="@gs_limits"
    cfsqltype="cf_sql_integer">
    <cfprocparam value="#gs_deductible#" dbvarname="@gs_deductible"
    cfsqltype="cf_sql_integer">
    <cfprocparam value="#schcredit#" dbvarname="@schcredit" cfsqltype="varchar">
    <cfprocparam value="#perss#" dbvarname="@perss" cfsqltype="cf_sql_decimal"
    scale="3">
    <cfprocparam value="#ghp#" dbvarname="@ghp" cfsqltype="cf_sql_decimal"
    scale="3">
    <cfprocparam value="#posttreats#" dbvarname="@posttreats"
    cfsqltype="cf_sql_decimal" scale="3">
    <cfprocparam value="#pretreats#" dbvarname="@pretreats"
    cfsqltype="cf_sql_decimal" scale="3">
    <cfprocparam value="#lopayroll#" dbvarname="@lopayroll"
    cfsqltype="cf_sql_decimal" scale="3">
    <cfprocparam value="#renwalreceipts#" dbvarname="@renwalreceipts"
    cfsqltype="cf_sql_decimal" scale="3">
    <cfprocparam value="#inspections#" dbvarname="@inspections"
    cfsqltype="cf_sql_decimal" scale="3">
    <cfprocparam value="#cm#" dbvarname="@cm" cfsqltype="cf_sql_decimal" scale="3">
    <cfprocparam value="#cmper#" dbvarname="@cmper" cfsqltype="cf_sql_decimal"
    scale="3">

    <cfprocresult name="rate_out">

    </cfstoredproc>

    SQL Stored Procedure:

    CREATE PROCEDURE [sp_rate]

    @gs_limits int,
    @gs_deductible int,
    @schcredit decimal(18,3),
    @cmper decimal(18,3),
    @cm decimal(18,3),
    @perss decimal(18,3),
    @ghp decimal(18,3),
    @posttreats decimal(18,3),
    @pretreats decimal(18,3),
    @lopayroll decimal(18,3),
    @fume decimal(18,3),
    @inspections decimal(18,3),
    @renwalreceipts decimal(18,3)

    AS

    /* -------------------------------------------------- Common Variables
    ------------------------------------------------- */


    declare @expfactor decimal(18,3)
    set @expfactor = '1.00'

    declare @ssper decimal(18,3)
    set @ssper = @perss * '.01'

    declare @percm decimal(18,3)
    set @percm = @cmper * '.01'


    /* -------------------------------------------------- Rates
    ---------------------------------------------------------------------- */

    declare @extrate decimal(18,3)
    select @extrate = rate from rate
    join classcode on classcode.classcodeid = rate.classcodeid
    where rate.classcodeid = '1' and limitid = @gs_limits


    declare @lorate decimal(18,3)
    select @lorate = rate from rate
    join classcode on classcode.classcodeid = rate.classcodeid
    where rate.classcodeid = '2' and limitid = @gs_limits

    declare @fumerate decimal(18,3)
    select @fumerate = rate from rate
    join classcode on classcode.classcodeid = rate.classcodeid
    where rate.classcodeid = '3' and limitid = @gs_limits

    declare @ssrate decimal(18,3)
    select @ssrate = rate from rate
    join classcode on classcode.classcodeid = rate.classcodeid
    where rate.classcodeid = '4' and limitid = @gs_limits

    /* -------------------------------------------------- Deductibles
    ------------------------------------------------------- */

    declare @extdeductdis decimal(18,3)
    select @extdeductdis = discount from deductiblediscount
    where classcodeid = '1' and deductiblediscount.deductibleid = @gs_deductible

    declare @lodeductdis decimal(18,3)
    select @lodeductdis = discount from deductiblediscount
    where classcodeid = '2' and deductiblediscount.deductibleid = @gs_deductible

    declare @fumedeductdis decimal(18,3)
    select @fumedeductdis = discount from deductiblediscount
    where classcodeid = '3' and deductiblediscount.deductibleid = @gs_deductible


    /* -------------------------------------------------- Exterm
    ------------------------------------------------------------ */

    declare @extfrate decimal(18,3)
    set @extfrate = (@extrate - @extdeductdis) * @schcredit * @expfactor


    /* -------------------------------------------------- Ext GHP
    ----------------------------------------------------------- */

    declare @ghpexp decimal(18,3)
    set @ghpexp = @ghp * (1 - @ssper)

    declare @ghpprem decimal(18,2)
    set @ghpprem = @extfrate * @ghpexp


    /* -------------------------------------------------- Ext Pre Treats
    ----------------------------------------------------- */


    declare @preexp decimal(18,3)
    set @preexp = @pretreats * (1 - @ssper)

    declare @preprem decimal(18,2)
    set @preprem = @extfrate * @preexp


    /* -------------------------------------------------- Ext Post Treats
    ----------------------------------------------------- */


    declare @postexp decimal(18,3)
    set @postexp = @posttreats * (1 - @ssper)

    declare @postprem decimal(18,2)
    set @postprem = @extfrate * @postexp


    /* -------------------------------------------------- Ext Total Prem
    ------------------------------------------------------- */

    declare @totalextprem decimal(18,2)
    set @totalextprem = @ghpprem + @preprem + @postprem


    /* -------------------------------------------------- LO
    -------------------------------------------------------------------- */


    declare @lofrate decimal(18,3)
    set @lofrate = (@lorate - @lodeductdis) * @schcredit * @expfactor


    declare @totalloprem decimal(18,2)
    set @totalloprem = @lofrate * @lopayroll


    /* -------------------------------------------------- Fume
    -------------------------------------------------------------------- */


    declare @fumefrate decimal(18,3)
    set @fumefrate = (@fumerate - @fumedeductdis) * @schcredit * @expfactor

    declare @fumeexp decimal(18,3)
    set @fumeexp = @fume * (1 - @ssper)

    declare @totalfumeprem decimal(18,2)
    set @totalfumeprem = @fumefrate * @fumeexp


    /* -------------------------------------------------- S&S
    ---------------------------------------------------------------------- */


    declare @ssfrate decimal(18,3)
    set @ssfrate = (@ssrate - @fumedeductdis) * @schcredit * @expfactor

    declare @ssghp decimal(18,3)
    set @ssghp = @ghp * @ssper

    declare @ssfume decimal(18,3)
    set @ssfume = @fume * @ssper

    declare @sspre decimal(18,3)
    set @sspre = @pretreats * @ssper

    declare @sspost decimal(18,3)
    set @sspost = @posttreats * @ssper

    declare @ssrenew decimal(18,3)
    set @ssrenew = @renwalreceipts * .25

    declare @ssinspect decimal(18,3)
    set @ssinspect = @inspections * .25

    declare @sscontmon decimal(18,3)
    set @sscontmon = @cm * @percm


    declare @ssexp decimal(18,3)
    set @ssexp = @ssghp + @ssfume + @sspre + @sspost + @sscontmon


    declare @ssprem decimal(18,3)
    set @ssprem = @ssfrate * @ssexp



    /* -------------------------------------------------- Output
    ------------------------------------------------------------------ */


    select @totalextprem as totalextprem, @totalloprem as totalloprem,
    @totalfumeprem as totalfumeprem, @ssprem as ssprem
    GO

    Web Page Error Message:

    Error Executing Database Query.
    [Macromedia][SQLServer JDBC Driver][SQLServer]Procedure 'sp_rate' expects
    parameter '@renwalreceipts', which was not supplied.

    The error occurred in C:\Data\CRUP\rate_output.cfm: line 40
    Called from C:\Data\CRUP\rate_output.cfm: line 1
    Called from C:\Data\CRUP\rate_output.cfm: line 40
    Called from C:\Data\CRUP\rate_output.cfm: line 1

    38 : <cfprocparam value="#cmper#" dbvarname="@cmper"
    cfsqltype="cf_sql_decimal" scale="3">
    39 :
    40 : <cfprocresult name="rate_out">
    41 :
    42 : </cfstoredproc>


    Sequenzia Guest

  2. Similar Questions and Discussions

    1. Stored Procedure call using MSSQL::DBLIB
      I'm trying to call a stored procedure from a perl script using the MSSQL::DBLIB module. My stored procedure requires three parameters (date, id #,...
    2. MSSQL Stored Procedure
      This is my first attempt at using sotred procedures, and a slight problem has come up. I'm collecting data to order a widget, and the first thing I...
    3. stored procedure problem
      I'm I Assign the value to the following store procedures correctly in vs.net? (The code is my only concern)...
    4. Can Flash call an MSSQL stored procedure?
      Is it possible to get Flash MX2004 pro to execute a stored procedure in a MSSQL database? Each time I run a particular SWF I would like the...
    5. ADO/Stored Procedure Problem
      After creating a new recordset and setting the cursor type to AdOpenStatic, I call a stored procedure thru the recordset's Open() method, and the...
  3. #2

    Default Re: MSSQL Stored Procedure Problem

    Have you tried placing the procparams in the exact order that they're expected in the SP?
    philh Guest

  4. #3

    Default Re: MSSQL Stored Procedure Problem

    To amplify what Phil Hegedusich said, you must place your CFPROCPARAM tags in
    the same order as they appear in your stored procedure spec, as the dbvarname
    attribute has been depricated in CF MX (unless you are using an older versin of
    CF).

    [url]http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-b16.htm#wp1102102[/url]
    Changed the dbvarname attribute behavior: it is now ignored for all drivers.
    ColdFusion MX uses JDBC 2.2 and does not support named parameters.

    Phil

    paross1 Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139