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!

trying to update a postgresql db

Status
Not open for further replies.

vz

MIS
Jul 31, 2001
131
US
HI,
I am trying to create a cold fusion update page that will work with a postgresql database. I have 2 primary keys in the table: order_id and accountnumber. order_id is a sequence/autonumber and its default is to increment the last value of order_id. I think this is whats causing my problem. My insert form works using this default but everytime I submit cf just hangs and eventually kicks me off of the server. If this is my problem ( iam open to any other ideas) how could I fix this where my insert form won't be messed up. Here is what the default of order_id looks like: nextval('seq_ordersplaced') this is what increments order_id, if I take this out it will mess up my insert form but possibly fix my update. Here is my code for the update:


<!DOCTYPE html public &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<CFQUERY name=&quot;UpdateRecord&quot; datasource=&quot;supply&quot;>
SELECT *
FROM ordersplaced
<!---populate the form with the record that matches the search criteria from the main page--->
WHERE order_id=#URL.orderid#
</CFQUERY>
<HTML>
<HEAD>
<TITLE>Supplies Orders Placed Form</TITLE>
<SCRIPT LANGUAGE=JAVASCRIPT>
//begin validation function
function validateInfo()
{
//declare variables to hold input values
var _accountname = document.updateordersplacedform.accountname.value;
var _tubes = document.updateordersplacedform.tubes.value;
var _needles = document.updateordersplacedform.needles.value;
var _butterfly = document.updateordersplacedform.butterfly.value;
var _sterilecontainer = document.updateordersplacedform.sterilecontainer.value;
var _tissuecontainer = document.updateordersplacedform.tissuecontainer.value;
var _sharps = document.updateordersplacedform.sharps.value;
var _gloves = document.updateordersplacedform.gloves.value;
var _misc = document.updateordersplacedform.misc.value;

//verify that certain input fields are filled in
if(_accountname.toString() ==&quot;&quot;)
{
alert(&quot;Please enter an Account Name.&quot;);
updateordersplacedform.accountname.focus();
return false;
}
if(_tubes.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Tubes EX.(0 or 10).&quot;);
updateordersplacedform.tubes.focus();
return false;
}
if(_needles.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Needles EX.(0 or 10).&quot;);
updateordersplacedform.needles.focus();
return false;
}
if(_butterfly.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Butterfly EX.(0 or 10).&quot;);
updateordersplacedform.butterfly.focus();
return false;
}
if (_sterilecontainer.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Sterile Container EX.(0 or 10).&quot;)
updateordersplacedform.sterilecontainer.focus();
return false;
}
if (_tissuecontainer.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Tissue Container EX.(0 or 10).&quot;)
updateordersplacedform.tissuecontainer.focus();
return false;
}
if (_sharps.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Sharps EX.(0 or 10).&quot;)
updateordersplacedform.sharps.focus();
return false;
}
if (_gloves.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Gloves EX.(0 or 10).&quot;)
updateordersplacedform.gloves.focus();
return false;
}
if(_misc.toString() ==&quot;&quot;)
{
alert(&quot;Please enter a numeric value for Misc EX.(0 or 10).&quot;)
updateordersplacedform.misc.focus();
return false;
}
}
</SCRIPT>
</HEAD>
<BODY bgcolor=&quot;cccccc&quot;>
<TABLE cellspacing=&quot;0&quot; cellpadding=&quot;0&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>
<CFOUTPUT>
<FONT size=&quot;2&quot; face=&quot;Arial&quot;>Please use your browsers &quot;reload&quot; function to view the most recent accounts.
You have updated the information in the Supplies Database.</FONT>
</CFOUTPUT>
<CFOUTPUT query=&quot;UpdateRecord&quot;>
<FORM name=&quot;updateordersplacedform&quot; action=&quot;updateordersplaceddata.cfm&quot; method=&quot;Post&quot;> <!---Order ID: - hidden--->
<INPUT type=&quot;hidden&quot; name=&quot;order_id&quot; value=&quot;#order_id#&quot;><BR>
<INPUT type=&quot;text&quot; name=&quot;accountnumber&quot; value=&quot;#accountnumber#&quot;><BR>
<FONT face=&quot;arial&quot; size=&quot;3&quot;>Account Name:</FONT>
<INPUT type=&quot;Text&quot; name=&quot;accountname&quot; value=&quot;#accountname#&quot; size=&quot;50&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; value=&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; value=&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; value=&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; value=&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; value=&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; value=&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; value=&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; value=&quot;#misc#&quot; size=&quot;10&quot; maxlength=&quot;50&quot;><BR><BR>
dateentered:<INPUT type=&quot;text&quot; name=&quot;dateentered&quot; value=&quot;#dateentered#&quot; size=&quot;8&quot; maxlength=&quot;8&quot;>
orderdate:<INPUT type=&quot;text&quot; name=&quot;orderdate&quot; value=&quot;#orderdate#&quot; size=&quot;8&quot; maxlength=&quot;8&quot;>


</TD>
</TR>
<TR>
<TD>
<!---Submit/Clear buttons--->
<A href=&quot;javascript: document.updateordersplacedform.submit()&quot;><IMG src=&quot;submit.gif&quot; onClick=&quot;return validateInfo();&quot; border=&quot;0&quot;></A>
<A href=&quot;javascript: document.updateordersplacedform.reset()&quot;><IMG src=&quot;clearchanges.gif&quot; border=&quot;0&quot;></A>
</TD>
</TR>
</TABLE>
</FORM>
</CFOUTPUT>
</BODY>
</HTML>


Here is my insert page code:


<!DOCTYPE html public &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<!---<CFQUERY name=&quot;getval&quot; datasource=&quot;supply&quot;>
Select max(order_id) as max_id from ordersplaced;
</CFQUERY>--->
<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()>
<!---<CFSET max_id = getval.max_id + 1>--->
<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;>
<!---<cfoutput>--->
<!---<INPUT type=&quot;hidden&quot; name=&quot;order_id&quot; size=&quot;8&quot; maxlength=&quot;8&quot; value=&quot;#order_id#&quot;>---><BR><FONT face=&quot;arial&quot; size=&quot;3&quot;>Account Number:</FONT>
<!---</cfoutput>--->
<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>


Could this even be the problem??
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top