Skip to main content
Known Participant
May 6, 2009
Question

error for the uploading csv file to database

  • May 6, 2009
  • 2 replies
  • 8929 views

Hi i tried to upload the csv file to database and i am getting error as

<cffile action="read" file="#data_dir_upload#/di_audit_corp_upc_ldr_tbl.csv" variable="di_audit_corp_upc_ldr_tbl">
<!--- loop through the CSV-TXT file on line breaks and insert into database --->
<cfloop index="index" list="#di_audit_corp_upc_ldr_tbl#" delimiters="#chr(10)##chr(13)#">
    <cfquery  datasource="#request.dsnCAO#">   
            <!--- SET ANSI_WARNINGS OFF      --->
         INSERT INTO [dbo].[di_audit_corp_upc_ldr_tbl]
                            ( cpt_dpt_cd,cpt_com_cd,sub_com_cd,con_upc_no,pid_lng_dsc_tx,pid_sht_dsc_tx)
         VALUES
                  (<cfqueryparam value='#left(trim(listgetAt('#index#',2,',')),2)#' cfsqltype="cf_sql_char">,
                   <cfqueryparam value='#left(trim(listgetAt('#index#',3,',')),3)#' cfsqltype="cf_sql_char">,
                   <cfqueryparam value='#left(trim(listgetAt('#index#',4,',')),5)#' cfsqltype="cf_sql_char">,
                   <cfqueryparam value='#left(trim(listgetAt('#index#',1,',')),13)#' cfsqltype="cf_sql_varchar">,                  
                   <cfqueryparam value='#left(trim(listgetAt('#index#',5,',')),25)#' cfsqltype="cf_sql_varchar">,
                   <cfqueryparam value='#left(trim(listgetAt('#index#',6,',')),12)#' cfsqltype="cf_sql_varchar">)    
   </cfquery>
</cfloop>

Error:
An error occurred while executing DTS package to import data.
Invalid list index 6.
In function ListGetAt(list, index [, delimiters]), the value of index, 6, is not a valid as the first argument (this list has 5 elements). Valid indexes are in the range 1 through the number of elements in the list.

i am unable to solve this issue can any one will help me to solve this issue

Thanks,

Kiran

This topic has been closed for replies.

2 replies

cfnewAuthor
Known Participant
May 6, 2009

thanks for ur help bob

Inspiring
May 6, 2009

It sounds like you have a row which only contains 5 items.  Can you post a sample of your CSV file?

cfnewAuthor
Known Participant
May 6, 2009

hi here i paste the data in csv file

UPCDeptCommSub Comm25 Character Desc - PID12 Character   Desc - PID
3.34E+09763698213FIGS BLACK MISSION DRDFIG BL DRD
3.34E+09763698213FIGS TURKEY BROWN DRDFIG BR DRD
4862763698213DATES PTDSF DAT DRD
2.05E+10763698213DATES PTDSF DAT DRD
3047763698210DATES MEDJOOL DRDDATES
Inspiring
May 6, 2009

I don't see an attachment.