Solved

updating a field with an additional item

Posted on 2002-07-08
5
158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

734 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