1 Replies - 1262 Views - Last Post: 16 December 2008 - 02:45 PM Rate Topic: -----

#1 dumper   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-December 08

deleete records from two tables

Posted 10 December 2008 - 09:10 AM

I have three tables where the information is stored, Item, Purchase, and Can. Each has a PurchaseID column to associate the entries except Can table doesn't has it.
i am a newer coldfusion.
Here is my code:
<cftransaction> 

<cfquery datasource="#Application.DSN#">
DELETE FROM Item
WHERE ITEM_UID = #ITEM_UID# 
</cfquery> 

<cfquery datasource="#Application.DSN#">
DELETE FROM Purchase
WHERE PUR_UID = #PUR_UID# 
</cfquery> 

</cftransaction> 



<cfquery name="GetItem" datasource="#Application.DSN#">
		SELECT ITEM_UID,NAME
		FROM Item
		ORDER BY NAME
</cfquery>
<html>
<head>
 <title>Deleting a Single Record</title>
</head>
<body>

<h4>Please select the Item(s) Number you wish to delete </h4>
<form action="test.cfm"method="post">
<table align="center" border="0">
<tr>
 <td><select name="ITEM_UID" size="5" multiple="multiple">
   <cfoutput query="GetItem">
	 <option value="#ITEM_UID#">#NAME#</option>
   </cfoutput>
 </select></td>
  </tr>
<tr>
   <td><cfinput type="hidden" name="PUR_UID" value="#PUR_UID#">
		</td>
	  </tr>
  
  <td align="center">
 <input type="submit" name="Delete" value="Delete"
  onclick="return confirm('Are you sure you want to delete the item purchase record?')">
  <a href="Itemmenu.cfm">Back to ITem Selection </a>  </td>
  </tr>
  </table>
</form>
  
  </body>
  </html>


Is This A Good Question/Topic? 0
  • +

Replies To: deleete records from two tables

#2 f150b0508   User is offline

  • New D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 25
  • Joined: 02-December 08

Re: deleete records from two tables

Posted 16 December 2008 - 02:45 PM

The problem might be that your select statement allows for the selection of multiple. So the query doesn't know how to delete it if more than one is selected at a time.

<select name="ITEM_UID" size="5" multiple="multiple">
   <cfoutput query="GetItem">
	 <option value="#ITEM_UID#">#NAME#</option>
   </cfoutput>
 </select>


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1