Hi i am trying to get some coldfusion web interfaces to work with postgresql, it already works with the same database in access however I keep getting and illegal operation and the program will shut down every time I try to insert a new record in one of my tables. This table has 2 primary keys: account_num and order_id. at first i was only asking for account_num b/c thats all I really need, but I kept getting an error regarding order_id being null when its supposed to be not null, so I added order_id into my form and now I am getting an illegal operation error, and I lose connection. Does anyone know why? I know in postgresql both fields have to have a value and they both are being given a value but its not working? Here is my coldfusion code:
Name-addordersplacedform.cfm
<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<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>
</HTML>
Name-postorderplaceddata.cfm
<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<CFINSERT datasource="supply" tablename="ordersplaced">
<HTML>
<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>
</HTML>
I have another table that works, but it only has 1 p key, this one has 2 and it doesn't work. Please help.
Thank You.
Name-addordersplacedform.cfm
<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<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>
</HTML>
Name-postorderplaceddata.cfm
<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<CFINSERT datasource="supply" tablename="ordersplaced">
<HTML>
<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>
</HTML>
I have another table that works, but it only has 1 p key, this one has 2 and it doesn't work. Please help.
Thank You.