hello
i have researched how to do this and my code appears to be correct (at least to me), but i need to enter data into 2 tables from one form action
my insert code is as follows:
<cfquery datasource="wcrh_physician
_signout">
INSERT INTO patient (patient_id, first_name, last_name, middle_name, dob, admit_date, med_rec_num, allergies, weight, weight_measurement, sex, race)
VALUES (
<cfif IsDefined("FORM.patient_id
") AND #FORM.patient_id# NEQ "">
'#FORM.patient_id#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.first_name
") AND #FORM.first_name# NEQ "">
'#FORM.first_name#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.last_name"
) AND #FORM.last_name# NEQ "">
'#FORM.last_name#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.middle_nam
e") AND #FORM.middle_name# NEQ "">
'#FORM.middle_name#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.dob") AND #FORM.dob# NEQ "">
'#FORM.dob#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.admit_date
") AND #FORM.admit_date# NEQ "">
'#FORM.admit_date#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.med_rec_nu
m") AND #FORM.med_rec_num# NEQ "">
'#FORM.med_rec_num#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.allergies"
) AND #FORM.allergies# NEQ "">
'#FORM.allergies#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.weight") AND #FORM.weight# NEQ "">
#FORM.weight#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.weight_mea
surement")
AND #FORM.weight_measurement# NEQ "">
'#FORM.weight_measurement#
'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.sex") AND #FORM.sex# NEQ "">
'#FORM.sex#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.race") AND #FORM.race# NEQ "">
'#FORM.race#'
<cfelse>
NULL
</cfif>
)
</cfquery>
<cfquery datasource="wcrh_physician
_signout">
INSERT INTO general (patient_id, subjective, o-t, o-hr)
VALUES (
'#FORM.patient_id#',
'#FORM.subjective#',
'#FORM.ot#',
'#FORM.ohr#'
)
</cfquery>
the coldfusion error i am getting is this:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
The error occurred in C:\Inetpub\darrenpedersen.
com\signou
t\insert_p
atient_act
ion.cfm: line 85
83 : '#FORM.subjective#',
84 : '#FORM.ot#',
85 : '#FORM.ohr#'
86 : )
87 : </cfquery>
--------------------------
----------
----------
----------
----------
----------
----
SQL INSERT INTO general (patient_id, subjective, o-t, o-hr) VALUES ( '5', 'NOT EXAMINED', 'NOT EXAMINED', '45ds' )
DATASOURCE wcrh_physician_signout
VENDORERRORCODE -3502
SQLSTATE 42000
even if i remove form.ohr then it just throws the error on o-t. i have tried wrapping them in cftransaction tags but still same issues...
Start Free Trial