CF_SQL_BIT works on Insert, not on Update

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

  1. #1

    Default CF_SQL_BIT works on Insert, not on Update

    Aaarrgghhh! For some reason, insert and update Stored Procedures are behaving
    differently, and there is not discernable reason for it. Here are the details:

    I've got a CFC object that is used to handle DB functions, among other things.
    My form's action page passes the #FORM# scope into a "set" method in this
    page, then calls either an insert or update method, depending on the value of
    the record ID.

    Both the Insert and Update methods use stored procedures to process the
    record. The code is nearly identical for both (in fact, the update was copied
    and pasted from the insert, then the record ID was added as an "in" parameter).
    There are no typos in either SP.

    Both of the Stored Procedures are nearly identical, and are written correctly,
    with no typos.

    "Insert" records are processed with no error messages. The data captured in
    the database is correct.

    "Update" records are throwing an error "Error converting data type varchar to
    bit. " Since both are using the same "set" method, this doesn't make sense.

    I've even tried adding an IIF to set the "true" "false" values to "1" and "0",
    but still got the same error.

    Any ideas????

    <cfset THIS.intPaymentTypeID = 0>
    <cfset THIS.strPaymentTypeName = "">
    <cfset THIS.blnIsCC = "false">

    <cffunction name="setPaymentTypeAttributes" access="public"
    returntype="boolean" output="false">
    <cfargument name="intPaymentTypeID" type="numeric" required="no" default="0">
    <cfargument name="strPaymentTypeName" type="string" required="no" default="">
    <cfargument name="blnIsCC" type="boolean" required="no" default="0">
    <cfif #ARGUMENTS.intPaymentTypeID# IS NOT 0><cfset THIS.intPaymentTypeID =
    #ARGUMENTS.intPaymentTypeID#></cfif>
    <cfif #ARGUMENTS.strPaymentTypeName# IS NOT ""><cfset
    THIS.strPaymentTypeName = "#ARGUMENTS.strPaymentTypeName#"></cfif>
    <cfif #ARGUMENTS.blnIsCC# IS NOT 0><cfset THIS.blnIsCC =
    #ARGUMENTS.blnIsCC#></cfif>
    <cfreturn true>
    </cffunction>

    <cffunction name="actInsertPaymentType" access="public" returntype="boolean"
    output="false">
    <cftransaction>
    <cfstoredproc procedure="ACTspInsertPaymentType"
    datasource="#REQUEST.mysql_dsn#" username="#REQUEST.mysql_username#"
    password="#REQUEST.mysql_password#">
    <cfprocparam type="in" value="#THIS.strPaymentTypeName#"
    cfsqltype="cf_sql_varchar">
    <cfprocparam type="in" value="#THIS.blnIsCC#" cfsqltype="cf_sql_bit">
    <cfprocparam type="out" variable="VARIABLE.intPaymentTypeID"
    cfsqltype="cf_sql_integer">
    </cfstoredproc>
    <cfquery name="qryGetNew" datasource="#REQUEST.mysql_dsn#"
    username="#REQUEST.mysql_username#" password="#REQUEST.mysql_password#">
    SELECT MAX(PaymentTypeID) AS intNew
    FROM ACTtbPaymentType
    </cfquery>
    <cfset THIS.intPaymentTypeID = #qryGetNew.intNew#>
    </cftransaction>
    <cfreturn true>
    </cffunction>

    <cffunction name="actUpdatePaymentType" access="public" returntype="boolean"
    output="false">
    <cfset VARIABLES.blnIsCC = #IIF(#THIS.blnIsCC# IS "true", DE(1), DE(0))#>
    <cfstoredproc procedure="ACTspInsertPaymentType"
    datasource="#REQUEST.mysql_dsn#" username="#REQUEST.mysql_username#"
    password="#REQUEST.mysql_password#">
    <cfprocparam type="in" value="#THIS.intPaymentTypeID#"
    cfsqltype="cf_sql_integer">
    <cfprocparam type="in" value="#THIS.strPaymentTypeName#"
    cfsqltype="cf_sql_varchar">
    <cfprocparam type="in" value="#VARIABLES.blnIsCC#" cfsqltype="cf_sql_bit">
    </cfstoredproc>
    <cfreturn true>
    </cffunction>

    DennisBelmont Guest

  2. Similar Questions and Discussions

    1. Update fails on CF 7.0, works on CF 5.0
      I'm not sure what's going on. The UPDATE below works with CF5.0 with MS Access ODBC, but fails with CF 7.0 with MS Access with Unicode. I first...
    2. update and insert query error, but select works ok.
      :rose; Any ideas spring to mind about the following issue? I'm getting an error trying to run an Update or Insert query. I can run a Select...
    3. DVD insert works but not in projector
      I can't get the DVD media to play in a projector. There's just the red crossed oblong to tell me it's missing the media so I put the Video_TS...
    4. Insert fails on access that I know works...
      Folks, I use PHP to write my form data to MySQL. I have a database with about ten tables. I'm trying to fill one table with some dummy data...
    5. update statement with DSN works, DSN-less fails
      the following SQL statement works when executing via a DSN connection but fails when using the DSN-less method. sql statement: UPDATE...
  3. #2

    Default Re: CF_SQL_BIT works on Insert, not on Update

    Could it possibly be a value problem of the parameter (VARIABLES.blnIsCC),
    rather than type? Also, have you tried to explicitly CAST the value of the
    input parameter to type BIT in the UPDATE .. SET statement within your stored
    proc?

    Phil

    paross1 Guest

  4. #3

    Default Re: CF_SQL_BIT works on Insert, not on Update

    I've tried a number of different ways to ensure that the value is a 1 or a 0;
    nothing's working. CAST doesn't work either, because it's never making it into
    the stored procedure - the error is being thrown while it's trying to pass the
    parameters in.

    DennisBelmont Guest

  5. #4

    Default Re: CF_SQL_BIT works on Insert, not on Update

    Maybe it would help to see the stored procedure, unless it is too much to display here. Also, you might try using cfsqltype="cf_sql_integer" for "#VARIABLES.blnIsCC#" in your update.

    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