Question
Dynamic update record based on field
Need help figuring this one out. I need to insert data from
one table into another table updating one field depending on what
that field is now. Here is the code I was trying but will not work
because of the I can't reference a table. Any help or suggestions
would be much appreciated.
<cfquery name="move00065" datasource="dbb_bcb">
INSERT INTO cust_data
SELECT t_030db.*
FROM t_030db
where store_num30 = '#FORM.numstore#'
on duplicate key update
<cfif cust_data.cstmrtyp eq "vf">
cstmrtyp = 'xc'
<cfelseif cust_data.cstmrtyp eq "we">
cstmrtyp='xc'
<cfelse>
cstmrtyp='zb'
</cfif>
,result = 'bbbb'
</cfquery>
<cfquery name="move00065" datasource="dbb_bcb">
INSERT INTO cust_data
SELECT t_030db.*
FROM t_030db
where store_num30 = '#FORM.numstore#'
on duplicate key update
<cfif cust_data.cstmrtyp eq "vf">
cstmrtyp = 'xc'
<cfelseif cust_data.cstmrtyp eq "we">
cstmrtyp='xc'
<cfelse>
cstmrtyp='zb'
</cfif>
,result = 'bbbb'
</cfquery>