Solved

updating a field with an additional item

Posted on 2002-07-08
5
149 Views
Last Modified: 2013-12-24
okay i have a micrsoft access database that contains a memo field which has a bunch of 9 digit numbers separated by spaces.

i.e

123456789 987456321 123789456 ....

i want to be able to update this field by adding a new 9 digit number to the end of it (i.e a space followed by the 9 digit number)

how do i do this?

 
0
Comment
Question by:sagardeo
5 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 7139025
besides querying, appending using CF and updating?

CJ
0
 

Author Comment

by:sagardeo
ID: 7139093
no that way is fine.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7139392
so you build a query:

<cfquery name="getCurrentData">
select columname
from tablename
where primary_key_column = foo
</cfquery>

<cfset getCurrentData.columname = getCurrentData.columname & " " & yourNewNumberVariable>

<cfquery name="updateData">
update tablename
set columname = '#getCurrentData.columname#'
where primary_key_column = foo
</cfquery>

if you give me the Db specifics and varnames I can give you the precise code.

HTH,
CJ
0
 
LVL 17

Expert Comment

by:anandkp
ID: 7140525
Hi,

Use a delimeter in ur Query as '~' so u can clearly distinguish the elements of the list.

the reason why i am saying this is having a delimeter is helpful [as in it increases the readability & also reduces the chances of errors]

when u want to append - use
cfset x = "ur originallist"
newlist = listappend(x,'new number','~')

but when u insert [newlist] in ur table - just use a replace fucntion on newlist & replace ur '~' with a " " & that should solve ur issue.

K'Rgds
Anand
0
 
LVL 2

Accepted Solution

by:
tleish earned 200 total points
ID: 7147630
You can do it in one query.  Append the numbers using the current name of the Table field row with the "&" concatination.

=== START CODE EXAMPLE ===

<cfset num = "987654321">
<cfquery name="qUpdate">
     update tableName
     set memoField = memoField & ' #variables.num#'
     where id = #myVar#
</cfquery>

=== END CODE EXAMPLE ===

If you have multiple items to update, just include it in that query.

=== START CODE EXAMPLE ===

<cfset num = "987654321">
<cfquery name="qUpdate">
     update tableName
     set name = '#newName#',
          address = '#newAddress#',
          memoField = memoField & ' #variables.num#'
     where id = #myVar#
</cfquery>

=== END CODE EXAMPLE ===
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question