Link to home
Start Free TrialLog in
Avatar of jerrykovach
jerrykovach

asked on

Updating multiple values

I am trying to set all phone_display values to 1 where the #phoneid# has been passed in.  Should I be using a <cfloop> tag?  Also, I am not able to display the records from the DisplayPhoneNumbers query.  


<!--- Begin Phone number Display Section --->

<cfif isDefined("form.phone")>
<CFQUERY NAME="UpdateContact_Phone1" DATASOURCE="O2K_DEV">
UPDATE     CFUSION.CONTACT_PHONE
SET             PHONE_DISPLAY=0
WHERE       (CONTACT_ID = 125)
</CFQUERY>
</cfif>  

<cfif isDefined("form.phone")>
<CFLOOP INDEX="phoneid" LIST="#form.phone#">
<CFQUERY NAME="UpdateContact_Phone" DATASOURCE="O2K_DEV">
UPDATE     CFUSION.CONTACT_PHONE
SET             PHONE_DISPLAY=1
WHERE       (PHONE_ID = #phoneid#)
</CFQUERY>
</CFLOOP>
</cfif>  

<cfif isDefined("form.phone")>
<CFQUERY NAME="DisplayPhoneNumbers" DATASOURCE="O2K_DEV">
SELECT      CONTACT_ID, PHONE_COMMENT, PHONE_NUMBER, PHONE_DISPLAY
FROM         CFUSION.CONTACT_PHONE
WHERE       (CONTACT_ID = 125) AND (PHONE_DISPLAY = 1)
</CFQUERY>
</cfif>
<table>

<cfif isDefined("form.phone")>
<cfoutput query="DisplayPhoneNumbers">
<tr>
      <td>#DisplayPhoneNumbers.PHONE_COMMENT#</td>
      <td>#DisplayPhoneNumbers.PHONE_NUMBER#</td>
</tr>
</cfoutput>
</cfif>

<!--- begin memo display --->
Avatar of deepchanda
deepchanda

i would assume that the form variable #form.phone# is comma separated otherwise your <cfloop> tag will need the delimiters parameter to say whats been used to separate the phone numbers in the list. Checking the table itself from your database queying tool to see if the rows got updated would be better idea.

DC
Avatar of jerrykovach

ASKER

I agree, the specific question here is how do I loop through the update statement.  

<cfif isDefined("form.phone")>
<CFLOOP INDEX="phoneid" LIST="#form.phone#">
<CFQUERY NAME="UpdateContact_Phone" DATASOURCE="O2K_DEV">
UPDATE     CFUSION.CONTACT_PHONE
SET             PHONE_DISPLAY=1
WHERE       (PHONE_ID = #phoneid#)
</CFQUERY>
</CFLOOP>
</cfif>  

I am passing in multipe values within the #form.phone# variable.  How do I use that information to loop through the update statement?

So is you LIST Form.Phone a Comma Delimited List?
questions is not clear. Please use an example string for what #form.phone# might have in the exact format. Do you want to make multiple updates within 1 update statement? is that the question?

Anusha
ASKER CERTIFIED SOLUTION
Avatar of Nathan Stanford Sr
Nathan Stanford Sr
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nathans,

I was able to figure this one out on my own.  In the future, I will be much more specific on questons asked.  I will give you full credit on this for responding in a very timely manner again.

Jerry