Solved

updating a field with an additional item

Posted on 2002-07-08
5
152 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

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Script 12 194
How to switch email hosts (part 2) 11 71
UPLOAD FILE TO Web API USING POST 5 132
setup wamp server for first time 2 102
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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