RE: How to update database from the data in a txt file

2000-03-31 Thread Dave Watts

 i have a text file with data like this:

 Student_ID Lic_No
 ---
 333   
 444   
 555   

 ... and so on.

 This is pure text file. In the database, I have a
 column called 'Student_ID'. I have created a new
 column called Lic_No in the database. I want to put
 the Lic_No info into the database.

 If I do it individually I would say:

 Update tbl_Student
 set Lic_No = ''
 where Student_ID = '333'

 But, it is going to be very painful to do it
 individually. I am sure there is an easy way. Can
 someone tell me how.

If you're going to do this from CF, you can read in the text file as a
variable, parse it as a list, then loop over the update:

CFFILE ACTION="READ" FILE="F:\Inetpub\wwwroot\test\readfile\data.txt"
VARIABLE="mylist"

CFSET mylist = ListRest(ListRest(mylist, Chr(13)), Chr(13))

CFLOOP INDEX="i" LIST="#mylist#" DELIMITERS="#Chr(13)#"

CFQUERY NAME="qUpdStudent" DATASOURCE="whatever"
UPDATE   tbl_Student
SET  Lic_No = '#ListFirst(i, " ")#'
WHEREStudent_ID = '#ListLast(i, " ")#'
/CFQUERY

/CFLOOP

However, you might do this using another tool instead of CF, if you can. For
example, if you can get the data to the database directly, you could parse
and import it within a stored procedure.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.



How to update database from the data in a txt file

2000-03-29 Thread mirza baig

i have  a text file with data like this:

Student_ID Lic_No
---
333   
444   
555   

... and so on.

This is pure text file. In the database, I have a
column called 'Student_ID'. I have created a new
column called Lic_No in the database. I want to put
the Lic_No info into the database. 

If I do it individually I would say:

Update tbl_Student
set Lic_No = ''
where Student_ID = '333'

But, it is going to be very painful to do it
individually. I am sure there is an easy way. Can
someone tell me how.

Thanks all.
Mirza


__
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.