| Newbie | | Join Date: Dec 2008 Location: Philadelphia
Posts: 1
| |
How do i convert a column with id letters in a file to a number 1 or 0 in coldfusion output....for example
'CON' or 'BUS' to be converted to an output of '0'and '1' (0 to represent CON and 1 for BUS)
The script is shown below the 'CustomerTypeID' column needs code that converts it from an "id" of ‘CON' or ‘BUS' to a "CustomerTypeId" of ‘0' or ‘1'. this is what the result i got when i ran the script below . I think it failed to insert to the table due to last column as shown below,not sure.
Error code - Error Code: 0
-
Error Message 226 Transfer complete.
-
rawinput length = 64 '8053717906', '15667154aa', 'CA', '0', 'CON' - Failed
-
rawinput length = 32 '3104224249', '15667545aa', 'NJ', '1', 'BUS' - Failed
-
Records inserted = 0
-
Failed to insert = 2
Script - <cfloop condition="len(rawInput) gt 30">
-
<!--- <cfset rowcnt=#rowcnt#+1> --->
-
<cfset Row = mid(RawInput,1,find(chr(10),RawInput,1)-1)><!--- selects first row of text file --->
-
rawinput length = <cfoutput>#len(rawInput)#</cfoutput>
-
<cfset Tn=#trim(ListGetAt(row, 1, "|"))#>
-
<cfset state=#trim(ListGetAt(row, 2, "|"))#>
-
<cfset region=#trim(ListGetAt(row, 3, "|"))#>
-
<cfset OrderNumber=#trim(ListGetAt(row, 4, "|"))#>
-
<cfset id=#trim(ListGetAt(row, 5, "|"))#>
-
-
-
-
<cfif #region# eq 2><cfset region = 0></cfif>
-
-
-
-
<cfoutput>
-
<cftry>
-
-
<cfquery name="insert" datasource="dispro">
-
insert into DslPortOutOrders
-
(dslphonenumber, Ordernumber, state, eastregion, CustomerTypeId)
-
values ('#tn#', '#Ordernumber#', '#state#', '#region#', '#id#')
-
</cfquery>
-
-
<cfset insertcnt=#insertcnt#+1>
-
'#tn#', '#Ordernumber#', '#state#', '#region#', '#id#'<br />
-
<cfcatch type="Any">
-
<font color="##FF0000">'#tn#', '#Ordernumber#', '#state#', '#region#', '#id#' - Failed</font><br />
-
<cfset Failcnt=#failcnt#+1>
-
</cfcatch>
-
</cftry>
-
</cfoutput>
-
<!--- Trims line just inserted from the text file. --->
-
<cfset RawInput = mid(RawInput,find(chr(10),RawInput,1)+1,len(rawInput))>
-
<!---<cfoutput>Length: #len(RawInput)#</cfoutput>--->
-
</cfloop>
|