> i have a text file with data like this:
>
> Student_ID     Lic_No
> ----------    ---------
> 333           11112222
> 444           22221111
> 555           33336666
>
> ... 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 = '11112222'
> 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, " ")#'
                WHERE    Student_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=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to