RE: Creating update statements on the fly

2002-04-02 Thread Jerry Staple

Try This


UPDATE tablename 
  
SET blah = '#form.blah#' 

   cfif isDefined(attributes.String1)
 ,string1 = attributes.String1
   /cfif
cfif isDefined(attributes.String2)
 ,string2 = attributes.String2
   /cfif

cfif isDefined(attributes.String3)
 ,string3 = attributes.String3
   /cfif


WHERE theid = #form.theid#


with regards to create the set you are going to have to set a flag
with what you want to update i.e. if the update button is clicked or a
hidden form value is equal to something if you explain the scenario I
will be able to advise you better but the above will give you the
ability to create a dynamic update statement without worrying about the
,.

Cheers

Jerry Staple
Web Application Developer   
Certified Coldfusion (5.0) Developer

Head Office 
133-137 Lisburn Road, Belfast   
Northern Ireland BT9 7AG
T  +44 (0) 28 9022 3224 
F  +44 (0) 28 9022 3223 
E  [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  
W  biznet-solutions.com http://www.biznet-solutions.com/  


 



 




From: Chakka, Sudheer [mailto:[EMAIL PROTECTED]]
Sent: 29 March 2002 16:10
To: CF-Talk
Subject: Creating update statements on the fly


HI,

  I wanted to create a Update statement on the fly. For creating a
Select
statement on the fly  I have used 
 
  Select * from tablename 
  Where 0=0
   cfif isDefined(attributes.String1)
 and String1 = attributes.String1
   /cfif
  

   How can I achieve this for update statement as I couldn't figure out
where to put Set statement and the last line with out coma(',')  in my
statement.

  Thanks in advance.

Sudheer Chakka.
  



__
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: Creating update statements on the fly

2002-03-29 Thread Rick Walters

There's always the ASP way...

!--- build the query ---
cfset sql=update tablename set  
cfif condition1...
  cfset sql=#sql#   columname=value
/cfif
cfif condition2...
  cfset sql=#sql#   where columname = 1
/cfif

cfquery name=myquery datasource=#dsn#
   #sql#
/cfquery


Good Fortune,
Richard Walters,
Webmaster, Davita Laboratory Services
[EMAIL PROTECTED]
(800) 604-5227 x 3525

 [EMAIL PROTECTED] 03/29/02 11:10AM 
HI,

  I wanted to create a Update statement on the fly. For creating a
Select
statement on the fly  I have used 
 
  Select * from tablename 
  Where 0=0
   cfif isDefined(attributes.String1)
 and String1 = attributes.String1
   /cfif
  

   How can I achieve this for update statement as I couldn't figure
out
where to put Set statement and the last line with out coma(',')  in my
statement.

  Thanks in advance.

Sudheer Chakka.
  



__
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists