MSSQL Stored Procedure

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

  1. #1

    Default 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 want to
    do is create an order ID, in this case called "prodID" wit a sotred procedure.
    I'm putting dummy values into the fields that do nto allow null:

    CREATE PROCEDURE NewProdForm
    @custUUID varchar (36),
    @pttType varchar(20),
    @pttWeight int,
    @initDate datetime,
    @delDate datetime,
    @prodID int = null OUTPUT
    AS

    -- make a new enpty line in the production table
    INSERT INTO production (custUUID, pttType, pttWeight, initDate,delDate)
    VALUES (@custUUID,@pttType,@pttWeight,@initDate,@delDate)

    -- send back the record number as prodID
    SET @prodID = @@IDENTITY
    RETURN 1

    GO

    In the page where I'm calling the stored procedure, I'm getting an error that
    the prodID variable doesn't exist.

    <CFSTOREDPROC procedure="microwavetelem.NewProdForm"
    datasource="microwavetelem" username="microwavetelem" password="#verb#">
    <CFPROCPARAM type="IN" dbvarname="@custUUID" value="#FORM.custUUID#"
    cfsqltype="CF_SQL_VARCHAR">
    <CFPROCPARAM type="IN" dbvarname="@pttType" value="PTT"
    cfsqltype="CF_SQL_VARCHAR">
    <CFPROCPARAM type="IN" dbvarname="@pttWeight" value="80"
    cfsqltype="CF_SQL_INTEGER">
    <CFPROCPARAM type="IN" dbvarname="@initDate" value="1/1/1900"
    cfsqltype="CF_SQL_TIMESTAMP">
    <CFPROCPARAM type="IN" dbvarname="@delDate" value="1/1/1900"
    cfsqltype="CF_SQL_TIMESTAMP">
    <CFPROCPARAM type="OUT" dbvarname="@prodID" variable="prodID"
    cfsqltype="CF_SQL_INTEGER">
    <CFPROCRESULT name="rsGetProdID">
    </CFSTOREDPROC>

    " Element PRODID is undefined in RSGETPRODID."

    What did I miss? I know the records are being created, but the ID isn't being
    provided to the next step in the process, which is to add that number in a
    field in another data table with a #rsGetProdID.prodID# to put the number where
    I want it.

    tempestweb 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 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...
    3. 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...
    4. MS SQL stored procedure
      I am new to MS SQL server and stored procedures. I currently have a query that looks like: select from table where fieldname IN...
    5. need help on a stored procedure
      I have 2 tables. table1 and table2 I do a select on table1 and join table 2 on id. I want to check newprice in table1. if it is null, I want to...
  3. #2

    Default Re: MSSQL Stored Procedure

    Try this:

    In your stored proc:

    change this:

    SET @prodID = @@IDENTITY
    RETURN 1

    to:

    SELECT @@IDENTITY as BPFID;
    RETURN(1)


    See if that works for ya.
    woodfoot Guest

  4. #3

    Default Re: MSSQL Stored Procedure

    sorry

    to:

    SELECT @@IDENTITY as prodID;
    RETURN(1)
    woodfoot Guest

  5. #4

    Default Re: MSSQL Stored Procedure

    Additionally, I do not believe you need the output parameter:

    <CFPROCPARAM type="OUT" dbvarname="@prodID" variable="prodID" cfsqltype="CF_SQL_INTEGER">

    I know I've never have had to use this...


    woodfoot Guest

  6. #5

    Default Re: MSSQL Stored Procedure

    This was copied from an example in CFMX7 Web Application Construction Kit; the CFPARAM OUT was there, so I used it. The

    SELECT @@IDENTITY as prodID;
    RETURN(1)

    worked. Thank you.
    tempestweb 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