Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting & Inserting Multiple rows in CFML?

Status
Not open for further replies.

habesha

Programmer
Oct 30, 2006
68
US



I am trying to develope application to insert and delete multiple rows at a time. I couldn't do it. Who can help me writing an example application?
 
To insert multiple rows, you'll need to loop through your data and do consequtive inserts with a <cfquery> tag. I would recommend reading up on the <cfloop> tag as this should do what you need.

To do multiple deletes, you can just do a standard delete and set your criteria to match whatever rows you want to delete. Here's an example:

<cfquery ...>
delete from table1 where idNum > 1 and idNum < 10
</cfquery>

This would delete all rows where the idNum is between 1 and 10.

Hope this helps,
GJ
 
To do multiple inserts you need to loop over your inset statement using the <CFLOOP> and pass the data to the query.

Multiple deletes can be done by passing a list of values

DELETE from table
WHERE customerID IN (#list#)

and list would contain your comma delimited list of ID's to delete

eg

1,3,5,6,11,90



Russ Michaels
russ@satachi.com
For my personal book recommendations visit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top