Thread View: borland.public.intrabuilder.data.sql
1 messages
1 total messages
Started by Billy Hildebrand
Sun, 18 Jan 1998 00:00
UNIQUE KEY CONSTRAINT! HELP!
Author: Billy Hildebrand
Date: Sun, 18 Jan 1998 00:00
Date: Sun, 18 Jan 1998 00:00
178 lines
7187 bytes
7187 bytes
I am reposting this plea for help. I have been looking at this bug in my
IntraBuilder application for two weeks now. This application is posted and
being sold to our customers. I don't know how this bug got through all of
the testing over an eight month period!?! This bug must get fixed soon or
... well I don't want to think about that.
If anyone can help with this or can point me to somewhere I can get help
with it would be appreciated. I will consider monetary rewards for
justifiable help.
There are four tables that use the following code to be saved. Three of the
four tables are updated correctly, one is not [ query_QAAIR - I get the
"unique key constraint" error].
Here is the code :
function saveData(callingForm, y, queryName, x) {
//this function is called from all the profile forms to save the data
that the user typed in. It is called
//once per form. It uses (recordCount) to know how many record to loop
through. (x) is the index of the current
//table (or query) used to access the tablesLables array.
var hostform = callingForm; //I had some problems using the
parameters directly, so I used vars instead
var success = true; //used to determine if the user left
a "not null" field blank
var s = ""; //the error (or success) string
returned by the function
try {
// _sys.scriptOut.writeln ('In: '+queryName+ y);
eval ("hostform."+queryName+".rowset.beginAppend()");
if ((queryName == "query_QAAIR") || (queryName == "query_QABILL")
||
(queryName == "query_QACAR") || (queryName == "query_QAHOTEL"))
//automatically set PREF_ORDER according to the order the
record appears on the form
eval ('hostform.'+queryName+'.rowset.fields["PREF_ORDER"].value
= prefCount');
for (z = 1; z <= hostform.tablesLabels[x].count; z++) {
//loop through all the fields in the current table
//this is the field's name that's used in the table
fieldName = eval ('hostform.tablesLabels[x].table' + z);
eval ('f = hostform.tablesLabels[x].table'+z);
if (hostform.selectBoxes.isKey ( f ))
if (eval ('hostform.select'+x+z+y+'.value == " "') &&
(queryName == "query_QATRAVL"))
eval ('hostform.'+queryName+'.rowset.fields ["'+f+'"].value =
" "');
else if (eval ('hostform.select'+x+z+y+'.value != " "')) {
_sys.scriptOut.writeln (f +" is not blank");
if (f != "EXPIRATION") {
//because the value in EXPIRATION is copied directly, not
converted to a code
eval (hostform.selectBoxes[f]+'(hostform)');
eval ('userSelect = hostform.select'+x+z+y+'.value');
tempIndex = hostform.arrayS.scan (userSelect);
if (tempIndex != -1)
c = hostform.arrayC [tempIndex];
else
c = " ";
eval ('hostform.'+queryName+'.rowset.fields ["'+f+'"].value
= c');
} //if !EXPIRATION
else
eval ('hostform.'+queryName+'.rowset.fields ["'+f+'"].value
= hostform.select'+x+z+y+'.value');
//add failure checking later
} //if not blank
else if (hostform.notNull.scan (fieldName) == -1) {
hostform.failure = true;
success = false;
eval ('s = hostform.tablesLabels[x].field'+z);
s += " At Column "+y+", In \"" +
hostform.tablesLabels[x].title+ "\" Is Blank.";
break;
}
} //if hostForm.selectBoxes
else {
//a text field ->make sure the field is not blank, or if it is
blank that it's not a "not null" field
if ((eval ("hostform.textField"+x+z+y+".value == ''")) &&
(hostform.notNull.scan (fieldName) == -1)) {
_sys.scriptOut.writeln ("not null");
hostform.failure = true;
success = false;
eval ('s = hostform.tablesLabels[x].field'+z);
s += " At Column "+y+", In \"" +
hostform.tablesLabels[x].title+ "\" Is Blank.";
break;
}
else
//just save
eval
('hostform.'+queryName+'.rowset.fields["'+fieldName+'"].value =
(hostform.textField'+x+z+y+'.value).toUpperCase()');
_sys.scriptOut.writeln (fieldName+ eval
('(hostform.textField'+x+z+y+'.value).toUpperCase()'));
} //else
} //else (text field)
} //for (z)
if (!success);
// break; //THIS IS ODD CODING!!!!!!!!!!!! previous
programmer...
else
if (recordCount > 0) {
//the condition is used so that if a user saves a totally blank
form, nothing is saved
//if the query is QATRAVL, automatically assign SUB to
TRAVELERID
if (queryName == "query_QATRAVL")
hostform.query_QATRAVL.rowset.fields["TRAVELERID"].value =
hostform.sub;
_sys.scriptOut.writeln
(hostform.sub+hostform.rezType+hostform.mainCode+hostform.cityCode);
eval ('hostform.'+queryName+'.rowset.fields["SUB"].value =
hostform.sub');
_sys.scriptOut.writeln ("IN KEYS");
eval ('hostform.'+queryName+'.rowset.fields["REZ"].value =
hostform.rezType');
eval ('hostform.'+queryName+'.rowset.fields["PCC"].value =
hostform.cityCode');
eval ('hostform.'+queryName+'.rowset.fields["MAIN"].value =
hostform.mainCode');
}
if (!success){
eval ("hostform."+queryName+".rowset.abandon()");
hostform.failure = true;
_sys.scriptOut.writeln ("!SAVED");
return s;
}
else {
if (recordCount > 0) {
//the condition is used so that if a user saves a totally blank
form, nothing is saved
hostform.failure = false;
_sys.scriptOut.writeln ("SAVED"+queryName);
return "Success";
}
} //(success)
} //try
catch (DbException e)
{
_sys.scriptOut.writeln ("DError in Saving:");
hostform.failure = true;
} //catch
catch (Exception e)
{
_sys.scriptOut.writeln ("Error in Saving:"+e.code+e.message);
hostform.failure = true;
} //catch
} //saveData.
Thanks,
Billy Hildebrand
webmaster@NOSPAMwwts.com
-please remove the NOSPAM when replying to this address
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads