Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Illegal operation regarding a not null in one of my 2 p keys

Status
Not open for further replies.

vz

MIS
Jul 31, 2001
131
US
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 &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
<TITLE>Supplies Database Place Order Form</TITLE>
<SCRIPT LANGUAGE=JAVASCRIPT>
//begin is numeric function
function isNum(passedVal)
{
if(passedVal ==&quot;&quot;)
{
return false
}
for (i=0; i<passedVal.length; i++)
{
if (passedVal.charAt(i) < &quot;0&quot;)
{
return false
}
if (passedVal.charAt(i) > &quot;9&quot;)
{
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(&quot;Please enter an Order Date in the format (mm/dd/yyyy).&quot;);
addordersplacedform.orderdate.focus();
return false;
}
if (date.charAt(2) != &quot;/&quot;)
{
alert(&quot;Please enter a foward slash '/' between month and day in the format (mm/dd/yyyy).&quot;);
addordersplacedform.orderdate.focus();
return false;
}
if (date.charAt(5) != &quot;/&quot;)
{
alert(&quot;Please enter a forward slash'/' between day and year in the format (mm/dd/yyyy).&quot;);
addordersplacedform.orderdate.focus();
return false;
}
if ((date.substring(0,2) < &quot;01&quot;) || (date.substring(0,2) > &quot;12&quot;))
{
alert(&quot;Please enter a valid month EX.(01 to 12).&quot;);
addordersplacedform.orderdate.focus();
return false;
}
if ((date.substring(3,5) < &quot;01&quot;) || (date.substring(3,5) > &quot;31&quot;))
{
alert(&quot;Please enter a valid day EX.(01 to 31).&quot;);
addordersplacedform.orderdate.focus();
return false;
}
if ((date.substring(6,10) < &quot;0000&quot;) || (date.substring(6,10) > &quot;9999&quot;))
{
alert(&quot;Please enter a valid year EX.(2000).&quot;);
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(&quot;Please enter a numeric Account Number.&quot;);
addordersplacedform.accountnumber.focus();
return false;
}
if(_accountname.toString() ==&quot;&quot;)
{
alert(&quot;Please enter an Account Name.&quot;);
addordersplacedform.accountname.focus();
return false;
}
if(_orderdate.toString() ==&quot;&quot;)
{
alert(&quot;Please enter an Order Date in the format (mm/dd/yy).&quot;);
addordersplacedform.orderdate.focus();
return false;
}
//calls function isDate to check date validity
if(isDate(_orderdate)== false)
{
addordersplacedform.orderdate.focus();
return false;
}
if(_tubes.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Tubes.&quot;);
addordersplacedform.tubes.focus();
return false;
}
if(_needles.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Needles.&quot;);
addordersplacedform.needles.focus();
return false;
}
if(_butterfly.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Butterfly.&quot;);
addordersplacedform.butterfly.focus();
return false;
}
if (_sterilecontainer.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Sterile Container.&quot;)
addordersplacedform.sterilecontainer.focus();
return false;
}
if (_tissuecontainer.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Tissue Container.&quot;)
addordersplacedform.tissuecontainer.focus();
return false;
}
if (_sharps.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Sharps.&quot;)
addordersplacedform.sharps.focus();
return false;
}
if (_gloves.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Gloves.&quot;)
addordersplacedform.gloves.focus();
return false;
}
if(_misc.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Misc.&quot;)
addordersplacedform.misc.focus();
return false;
}
}
//end validation function
</SCRIPT>
</HEAD>

<!---Get Date--->
<CFSET DATEENTERED = NOW()>
<BODY bgcolor=&quot;cccccc&quot;>
<TABLE height=&quot;100%&quot; width=&quot;100%&quot; cellspacing=&quot;3&quot; cellpadding=&quot;5&quot;>
<TR>
<TD><FONT face=&quot;arial&quot; size=&quot;6&quot;><B>Orders Placed</B></FONT>
</TD>
<TD>
<!---Link back to main page--->
<A href=&quot;mainsuppliesdbpage.cfm&quot;><IMG src=&quot;mainpage.gif&quot; border=&quot;0&quot;></A>
</TD>
</TR>
<TR>
<TD>
<FORM name=&quot;addordersplacedform&quot; action=&quot;postordersplaceddata.cfm&quot; method=&quot;Post&quot;><FONT face=&quot;arial&quot; size=&quot;3&quot;>Order ID:
<INPUT type=&quot;Text&quot; name=&quot;order_id&quot; size=&quot;8&quot; maxlength=&quot;8&quot;><BR><FONT face=&quot;arial&quot; size=&quot;3&quot;>Account Number:</FONT>
<INPUT type=&quot;Text&quot; name=&quot;accountnumber&quot; size=&quot;8&quot; maxlength=&quot;8&quot;><BR><FONT face=&quot;arial&quot; size=&quot;3&quot;>Account Name:</FONT>
<INPUT type=&quot;Text&quot; name=&quot;accountname&quot; size=&quot;50&quot; maxlength=&quot;50&quot;><BR><FONT face=&quot;arial&quot; size=&quot;3&quot;>Order Date:</FONT>
<INPUT type=&quot;Text&quot; name=&quot;orderdate&quot; size=&quot;10&quot; maxlength=&quot;50&quot;><BR><FONT face=&quot;arial&quot; size=&quot;3&quot;>Tubes:</FONT>
<INPUT type=&quot;Text&quot; name=&quot;tubes&quot; size=&quot;10&quot; maxlength=&quot;50&quot;><BR><FONT face=&quot;arial&quot; size=&quot;3&quot;>Needles:</FONT>
<INPUT type=&quot;Text&quot; name=&quot;needles&quot; size=&quot;10&quot; maxlength=&quot;50&quot;><BR><FONT face=&quot;arial&quot; size=&quot;3&quot;>Butterfly:</FONT>
<INPUT type=&quot;Text&quot; name=&quot;butterfly&quot; size=&quot;10&quot; maxlength=&quot;50&quot;><BR><FONT face=&quot;arial&quot; size=&quot;3&quot;>Sterile Containers:</FONT>
<INPUT type=&quot;Text&quot; name=&quot;sterilecontainer&quot; size=&quot;10&quot; maxlength=&quot;50&quot;><BR><FONT face=&quot;arial&quot; size=&quot;3&quot;>Tissue Container:</FONT>
<INPUT type=&quot;Text&quot; name=&quot;tissuecontainer&quot; size=&quot;10&quot; maxlength=&quot;50&quot;><BR><FONT face=&quot;arial&quot; size=&quot;3&quot;>Sharps:</FONT>
<INPUT type=&quot;Text&quot; name=&quot;sharps&quot; size=&quot;10&quot; maxlength=&quot;50&quot;><BR><FONT face=&quot;arial&quot; size=&quot;3&quot;>Gloves:</FONT>
<INPUT type=&quot;Text&quot; name=&quot;gloves&quot; size=&quot;10&quot; maxlength=&quot;50&quot;><BR><FONT face=&quot;arial&quot; size=&quot;3&quot;>Misc:</FONT>
<INPUT type=&quot;Text&quot; name=&quot;misc&quot; size=&quot;10&quot; maxlength=&quot;50&quot;><BR><!---Date Entered: - hidden--->
<CFOUTPUT>
<INPUT type=&quot;hidden&quot; name=&quot;dateentered&quot; value=&quot;#dateentered#&quot;><BR>
</CFOUTPUT>
</TD>
</TR>
<TR>
<TD>
<!---Submit/reset buttons--->
<A href=&quot;javascript: document.addordersplacedform.submit()&quot;><IMG src=&quot;submit.gif&quot; onClick=&quot;return validateInfo();&quot; border=&quot;0&quot;></A>
<A href=&quot;javascript: document.addordersplacedform.reset()&quot;><IMG src=&quot;clearform.gif&quot; border=&quot;0&quot;></A>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>

Name-postorderplaceddata.cfm
<!DOCTYPE html public &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<CFINSERT datasource=&quot;supply&quot; tablename=&quot;ordersplaced&quot;>
<HTML>
<HEAD>
<TITLE>Supplies Orders Placed Input Confirmation</TITLE>
</HEAD>
<BODY bgcolor=&quot;CCCCCC&quot;>
<TABLE CELLPADDING=&quot;5&quot; CELLSPACING=&quot;3&quot; height=&quot;100%&quot; width=&quot;100%&quot;>
<TR>
<TD>
<FONT size=&quot;6&quot; face=&quot;Arial&quot;><B>Order Added</B></FONT>
</TD>
<TD>
<A href=&quot;mainsuppliesdbpage.cfm&quot;><IMG src=&quot;mainpage.gif&quot; border=&quot;0&quot;></A>
</TD>
</TR>
<TR>
<TD>
<CFOUTPUT>
<FONT size=&quot;3&quot; face=&quot;Arial&quot;><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.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top