Solved

updating a field with an additional item

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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