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!

Unable to upload data into SQL

Status
Not open for further replies.

Firsttimeprogrammer

Programmer
Feb 10, 2005
8
US
I have been trying to upload a csv file into oracle for the past 2 weeks and unable to do so. The data can only be entered if the first field is unique and if not to go to the next record. The problem is that I have fields in the csv file that are null and when the data is upload the fields are entered incorrectly on my database table.

Could someone please look at this code and tell me what I am doing wrong.As my deadline to submit this is today?

Here is my code


<html>
<head>
<title>File Upload </title>
</head>
<body>
<cfif isdefined("form.upload_now")>

<cffile action="upload" destination="#expandPath('.')#" filefield="ul_path" nameconflict="overwrite">

<cf_uploadCSV csv_path="#form.ul_path#" r_query="myQuery">

<cfparam name="variables.tempMatchText" default="">

<cfloop query="myQuery">

<cfset I = myQuery.CurrentRow>
<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.appl_name = "">
<cfset variables.addr_text = "">
<cfset variables.contact = "">
<cfset variables.director_telephone_no = "">
<cfset variables.director_email_addr = "">
<cfset variables.stat_cd = "">


<!---Begin - Insert Course Reords--->
<!---declare all the values to the temporary variables--->
<cfset variables.prawardnumber = myQuery.ITEM1>
<cfset variables.perf_perd_begin_dt = #DateFormat(myQuery.ITEM2, "mm/dd/yyyy")#>
<cfset variables.perf_perd_end_dt = #DateFormat(myQuery.ITEM3, "mm/dd/yyyy")#>
<cfset variables.appl_name = myQuery.ITEM4>
<cfset variables.addr_text= myQuery.ITEM5>
<cfset variables.contact = myQuery.ITEM6>
<cfset variables.director_telephone_no = myQuery.ITEM7>
<cfset variables.director_email_addr = myQuery.ITEM8>
<cfset variables.stat_cd = myQuery.ITEM9>

<cfset variables.matchText = variables.prawardnumber>


<cfif variables.matchText NEQ variables.tempMatchText>

<cfquery name="myQuery1" datasource="eeliasnew">
Insert into
TB_NRC_testUPLOAD (prawardnumber,perf_perd_begin_dt,perf_perd_end_dt,institution_name,address,director_name ,director_telephone,director_email,st_cd)
Values ('#myQuery.ITEM1#',
to_date('#variables.perf_perd_begin_dt#','mm/dd/yyyy'),
to_date('#variables.perf_perd_end_dt#','mm/dd/yyyy'),
nvl('#variables.appl_name#',null),
nvl('#variables.addr_text#',null),
nvl('#variables.contact#',null),
nvl('#variables.director_telephone_no#',null),
nvl('#variables.director_email_addr#',null),
nvl('#variables.stat_cd#',null))
</CFQUERY>

</cfif>
<cfset variables.tempMatchText = variables.prawardnumber>
</cfif>
</cfloop>
<br>Successful Upload<br><br>
</cfif>


<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" onKeyPress="checkFileSelection();">
<input type="file" name="ul_path" id="ul_path">
</center>
<br>Be sure "after" you click "Submit" you get a "Successful Upload"!
<br><br>
<input type="submit" name="upload_now" value="submit">

</form>
</center>


<br>
</body>
</html>
 
Have you considered doing this processing on the Oracle side. Like a dts package or a stored procedure. An argument could be made that it would be alot faster on the database server than on the web server.
 
DTS i beleive is for SS only. check the oracle forum and see if oracle has an easy way to import csv.

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