Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

csv file and insert fields into oracle using coldfusion

Status
Not open for further replies.

Firsttimeprogrammer

Programmer
Feb 10, 2005
8
US
Could any one tell me how to insert records from a csv file into oracle. The problem is there are 12 fields in the csv file but only three fields that are to be inserted.

For example I have col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col11,col12,. But only need col1, col3 and col4 to be inserted.

The condition for the insert is if column 5 is empty..
 
what do you have so far?

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
Here is what I have.


<html>
<head>
<title>File Upload </title>
</head>
<body>
<div align="center"><h2>NRC FILE UPLOAD PAGE</h2> </div>
<br>
<br>
Click the "Browse Button, then find the project file you wish to upload
<center>
<form action="cf_upload.cfm" method="post" name="upload_form" enctype="multipart/form-data" id="upload_form">
<input type="file" name="ul_path" id="ul_path">
</center>
<br>Be sure "after" you click "Submit" you get a "Successful Upload" message just below this line!
<br><br>

<input type="submit" name="upload_now" value="submit">
</form>

Have a problem uploading? <a href="mailto:eelias@cbmiweb.com">Email Me</a>
</center>


<cfif isdefined("form.upload_now")>
<cf_uploadCSV csv_path="#form.ul_path#" r_query="myQuery">
<cffile action="upload" filefield="ul_path" destination="#expandPath('.')#" nameconflict="makeunique">
<cffile action="read" file="#expandpath(cffile.ServerFile)#" variable="fileData">


<cfloop query="myQuery">
<cfset I = myQuery.CurrentRow>
here I am
<cfif I GT 1 and len(myQuery.ITEM1) gt 0>
<cfset variables.prawardnumber = "">
<cfset variables.perf_perd_begin_dt = "">
<cfset variables.perf_perd_end_dt = "">
<cfset variables.acct_classification_code = "">

<cfset variables.acct_classification_code = myQuery.ITEM4>

<!---Begin - Insert Course Reords--->
<cfif variables.acct_classification_code EQ "">
<!---declare all the values to the temporary variables--->
<cfset variables.prawardnumber = myQuery.ITEM1>
<cfset variables.perf_perd_begin_dt = myQuery.ITEM2>
<cfset variables.perf_perd_end_dt = myQuery.ITEM3>

<!---Insert into Table_UPLOAD(prawardnumber,perf_perd_end_dt,perf_perd_begin_dt)
Values (myQuery.ITEM2,myQuery.ITEM3,myQuery.ITEM4>--->
<cfoutput>
one row updated
#variables.courseRecNum#
</cfoutput>


</cfif> <!---End - Start from the third row --->
</cfif>

</cfloop>

</cfif>


<br>
</body>
</html>
 
look into cfhttp and get the contents of the csv file like a query vice looping through an open file.


If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top