I am trying to creat an insert form with cold fusion and postgresql. I already have these forms working with access, but it will not work with postgresql. I have 2 primary keys in my table and I think that has something to do with the problem, i just don't know how to fix it. I have another table and insert form with only 1 primary key and it works fine. this is the error that I am getting:
ODBC Error Code = S1000 (General error)
Error while executing the query; ERROR: ExecAppend: Fail to add null value in not null attribute order_id
Here is my code - there are 2 pages I have commented out some of the things that I have tried:
Name: addordersplacedform.cfm
<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<HEAD>
<TITLE>Supplies Database Place Order Form</TITLE>
<SCRIPT LANGUAGE=JAVASCRIPT>
//begin is numeric function
function isNum(passedVal)
{
if(passedVal =="")
{
return false
}
for (i=0; i<passedVal.length; i++)
{
if (passedVal.charAt(i) < "0")
{
return false
}
if (passedVal.charAt(i) > "9")
{
return false
}
}
return true
}//end is numeric function
//begin is date function - This function checks to see if the
//date is in the correct format.
function isDate(date)
{
if (date.length != 10)
{
alert("Please enter an Order Date in the format (mm/dd/yyyy).");
addordersplacedform.orderdate.focus();
return false;
}
if (date.charAt(2) != "/")
{
alert("Please enter a foward slash '/' between month and day in the format (mm/dd/yyyy).");
addordersplacedform.orderdate.focus();
return false;
}
if (date.charAt(5) != "/")
{
alert("Please enter a forward slash'/' between day and year in the format (mm/dd/yyyy).");
addordersplacedform.orderdate.focus();
return false;
}
if ((date.substring(0,2) < "01") || (date.substring(0,2) > "12"))
{
alert("Please enter a valid month EX.(01 to 12).");
addordersplacedform.orderdate.focus();
return false;
}
if ((date.substring(3,5) < "01") || (date.substring(3,5) > "31"))
{
alert("Please enter a valid day EX.(01 to 31).");
addordersplacedform.orderdate.focus();
return false;
}
if ((date.substring(6,10) < "0000") || (date.substring(6,10) > "9999"))
{
alert("Please enter a valid year EX.(2000).");
addordersplacedform.orderdate.focus();
return false;
}
}
//end is date function
//begin main validation function
function validateInfo()
{
//declare variables to hold input values
var accountnumber = document.addordersplacedform.accountnumber.value;
var accountname = document.addordersplacedform.accountname.value;
var orderdate = document.addordersplacedform.orderdate.value;
var tubes = document.addordersplacedform.tubes.value;
var needles = document.addordersplacedform.needles.value;
var butterfly = document.addordersplacedform.butterfly.value;
var sterilecontainer = document.addordersplacedform.sterilecontainer.value;
var tissuecontainer = document.addordersplacedform.tissuecontainer.value;
var sharps = document.addordersplacedform.sharps.value;
var gloves = document.addordersplacedform.gloves.value;
var _misc = document.addordersplacedform.misc.value;
//verify that certain input fields are filled in
if(isNum(accountnumber) == false)
{
alert("Please enter a numeric Account Number.");
addordersplacedform.accountnumber.focus();
return false;
}
if(accountname.toString() =="")
{
alert("Please enter an Account Name.");
addordersplacedform.accountname.focus();
return false;
}
if(orderdate.toString() =="")
{
alert("Please enter an Order Date in the format (mm/dd/yy).");
addordersplacedform.orderdate.focus();
return false;
}
//calls function isDate to check date validity
if(isDate(orderdate)== false)
{
addordersplacedform.orderdate.focus();
return false;
}
if(tubes.toString() =="")
{
alert("Please enter a numeric value for Tubes.");
addordersplacedform.tubes.focus();
return false;
}
if(needles.toString() =="")
{
alert("Please enter a numeric value for Needles.");
addordersplacedform.needles.focus();
return false;
}
if(butterfly.toString() =="")
{
alert("Please enter a numeric value for Butterfly.");
addordersplacedform.butterfly.focus();
return false;
}
if (sterilecontainer.toString() =="")
{
alert("Please enter a numeric value for Sterile Container.")
addordersplacedform.sterilecontainer.focus();
return false;
}
if (tissuecontainer.toString() =="")
{
alert("Please enter a numeric value for Tissue Container.")
addordersplacedform.tissuecontainer.focus();
return false;
}
if (sharps.toString() =="")
{
alert("Please enter a numeric value for Sharps.")
addordersplacedform.sharps.focus();
return false;
}
if (gloves.toString() =="")
{
alert("Please enter a numeric value for Gloves.")
addordersplacedform.gloves.focus();
return false;
}
if(misc.toString() =="")
{
alert("Please enter a numeric value for Misc.")
addordersplacedform.misc.focus();
return false;
}
}
//end validation function
</SCRIPT>
</HEAD>
<!---Get Date--->
<CFSET dateentered = NOW()>
<BODY bgcolor="cccccc">
<TABLE height="100%" width="100%" cellspacing="3" cellpadding="5">
<TR>
<TD><FONT face="arial" size="6"><B>Orders Placed</B></FONT>
</TD>
<TD>
<!---Link back to main page--->
<A href="mainsuppliesdbpage.cfm"><IMG src="mainpage.gif" border="0"></A>
</TD>
</TR>
<TR>
<TD>
<FORM name="addordersplacedform" action="postordersplaceddata.cfm" method="Post"><FONT face="arial" size="3"><!---Order ID:
<INPUT type="Text" name="order_id" size="8" maxlength="8"><BR>---><FONT face="arial" size="3">Account Number:</FONT>
<INPUT type="Text" name="accountnumber" size="8" maxlength="8"><BR><FONT face="arial" size="3">Account Name:</FONT>
<INPUT type="Text" name="accountname" size="50" maxlength="50"><BR><FONT face="arial" size="3">Order Date:</FONT>
<INPUT type="Text" name="orderdate" size="10" maxlength="50"><BR><FONT face="arial" size="3">Tubes:</FONT>
<INPUT type="Text" name="tubes" size="10" maxlength="50"><BR><FONT face="arial" size="3">Needles:</FONT>
<INPUT type="Text" name="needles" size="10" maxlength="50"><BR><FONT face="arial" size="3">Butterfly:</FONT>
<INPUT type="Text" name="butterfly" size="10" maxlength="50"><BR><FONT face="arial" size="3">Sterile Containers:</FONT>
<INPUT type="Text" name="sterilecontainer" size="10" maxlength="50"><BR><FONT face="arial" size="3">Tissue Container:</FONT>
<INPUT type="Text" name="tissuecontainer" size="10" maxlength="50"><BR><FONT face="arial" size="3">Sharps:</FONT>
<INPUT type="Text" name="sharps" size="10" maxlength="50"><BR><FONT face="arial" size="3">Gloves:</FONT>
<INPUT type="Text" name="gloves" size="10" maxlength="50"><BR><FONT face="arial" size="3">Misc:</FONT>
<INPUT type="Text" name="misc" size="10" maxlength="50"><BR><!---Date Entered: - hidden--->
<CFOUTPUT>
<INPUT type="hidden" name="dateentered" value="#dateentered#"><BR>
</CFOUTPUT>
</TD>
</TR>
<TR>
<TD>
<!---Submit/reset buttons--->
<A href="javascript: document.addordersplacedform.submit()"><IMG src="submit.gif" onClick="return validateInfo();" border="0"></A>
<A href="javascript: document.addordersplacedform.reset()"><IMG src="clearform.gif" border="0"></A>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
Name: postordersplaceddata.cfm
<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<CFINSERT datasource="supply" tablename="ordersplaced">
<HEAD>
<TITLE>Supplies Orders Placed Input Confirmation</TITLE>
</HEAD>
<BODY bgcolor="CCCCCC">
<TABLE CELLPADDING="5" CELLSPACING="3" height="100%" width="100%">
<TR>
<TD>
<FONT size="6" face="Arial"><B>Order Added</B></FONT>
</TD>
<TD>
<A href="mainsuppliesdbpage.cfm"><IMG src="mainpage.gif" border="0"></A>
</TD>
</TR>
<TR>
<TD>
<CFOUTPUT>
<FONT size="3" face="Arial"><I>You have added:</I><BR><!---#Form.order_id# --->Account Number: <B>#Form.accountnumber#</B><BR>Account Name: <B>#Form.accountname#</B><BR>Order Date: <B>#Form.orderdate#</B><BR>Tubes: <B>#Form.tubes#</B><BR>Needles: <B>#Form.needles#</B><BR>Butterflies: <B>#Form.butterfly#</B><BR>Sterile Containers: <B>#Form.sterilecontainer#</B><BR>Tissue Containers: <B>#Form.tissuecontainer#</B><BR>Sharps: <B>#Form.sharps#</B><BR>Gloves: <B>#Form.gloves#</B><BR>Misc: <B>#Form.misc#</B><BR><!---#Form.DateEntered#--->
</CFOUTPUT>
</TD>
</TR>
</TABLE>
</BODY>
I have 2 primary keys accountnumber and order_id only accountnumber is being used in my form.
Please help!