Firsttimeprogrammer
Programmer
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>
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>