Syntax is a little off.  Also, make sure that you have the 'percentage'
field in the database correctly marked as a numeric field and not a
character field.

My advice is to purchase an SQL book, mine is dogeared to death from all
the use it gets....

"SQL Complete Refernce" - isbn # 0-07-211845-8 - definitely the best book i
have seen.

While you're at it, pick up Ben's book(s) on CF - "CFMX Application
Construction Kit" isbn # 0-321-12516-9

<CFQUERY name="change" datasource="printprices">
   UPDATE bookinfo
   SET    percentage = <cfqueryparam cfsqltype="CF_SQL_NUMERIC"
value="#form.percentage#"> ,
          discountedprice = price
   WHERE  bookid = 4
</cfquery>

Ray
http:/www.crystalvision.org

At 10:50 AM 3/30/2004, Robert Orlini wrote:
>I get an error Peter (see below). I want to update all in the percentage
>column to the value of form.percentage (which will be 0) and in each of
>those records I want discountedprice to be set to the same as the price
>value. Discountedprice, price are decimal fields.
>ODBC Error Code = 37000 (Syntax error or access violation)
>[Microsoft][ODBC SQL Server Driver][SQL Server]Line 2: Incorrect syntax
>near '@P1'.
>SQL = "Update bookinfo ? , discountprice = price Where bookid = 4" Query
>Parameter Value(s) - Parameter #1 = 0 Data Source = "PRINTPRICES"
>
>
>Code is:
><cfif IsDefined("form.percentage")>
><CFQUERY name="change" datasource="printprices">
>Update bookinfo
><cfqueryparam cfsqltype="CF_SQL_NUMERIC"
>value="#form.percentage#"> , discountprice = price
>Where bookid = 4
></cfquery>
>done
></cfif>
>
>-----Original Message-----
>From: Pascal Peters [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, March 30, 2004 10:38 AM
>To: CF-Talk
>Subject: RE: Update price
>
>
>SET percentage = <cfqueryparam cfsqltype="CF_SQL_NUMERIC"
>value="#form.percentage#"> ,
>discountprice = price
>WHERE ...
>
>Assuming your percentage is numeric. I see you have quotes around it, so
>mayby it's a varchar (CF_SQL_VARCHAR)
>
>Don't forget the WHERE clause or you will update all records in the
>table
>
> > -----Original Message-----
> > From: Robert Orlini [mailto:[EMAIL PROTECTED]
> > Sent: dinsdag 30 maart 2004 17:24
> > To: CF-Talk
> > Subject: Update price
> >
> > I have a query in an action page where I set a column to 0
> > (from a form) and update discountedprice to the same value as
> > price. Here is the code:
> >
> > <CFQUERY name="change" datasource="printprices"> Update
> > bookinfo SET percentage = '#form.percentage#'
> > SET 'discountedprice' = 'price'
> > </cfquery>
> >
> > I'm kinda a newy to all this so of course it doesn't work. I
> > get an error with -- SET 'discountedprice' = 'price'
> >
> > Any ideas please? Thanks.
> >
> > Robert O.
> > HWW
> >
> >
>   _____
>
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to