Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Bug Reports (Open)
 Bug: admin_mod_dbsetup.asp
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Nathan
Help Moderator

USA
7664 Posts

Posted - 06 April 2002 :  17:10:54  Show Profile  Visit Nathan's Homepage
Assuming the specs shown in this thread the dbs file should allow for an update statement without a WHERE clause (to update all records in the database)

The loop that preforms the updates looks like this. (about line 440)
	for y = 0 to numfields-1
if Instr(strTableName,"MEMBER",1) > 0 then
strSql = "UPDATE " & strMemberTablePrefix & strTableName & " SET"
else
strSql = "UPDATE " & strTablePrefix & strTableName & " SET"
end if
tmpArray = split(fieldArray(y),"#")
fName = tmpArray(0)
fValue = tmpArray(1)
fwhere = tmpArray(2)
strSql = strSql & " " & fName & " = " & fvalue & " WHERE " & fWhere
my_Conn.Execute strSql

next


There is a problem in that this function never checks to see if the fWhere (or Where clause) is an empty string or not. It will put "WHERE" in the sql string either way. When the Where caluse is then left blank, the database throws an error.
To solve it there should be an if structure to check the fWare variable for an empty string.

	for y = 0 to numfields-1
if Instr(strTableName,"MEMBER",1) > 0 then
strSql = "UPDATE " & strMemberTablePrefix & strTableName & " SET"
else
strSql = "UPDATE " & strTablePrefix & strTableName & " SET"
end if
tmpArray = split(fieldArray(y),"#")
fName = tmpArray(0)
fValue = tmpArray(1)
fwhere = tmpArray(2)
strSql = strSql & " " & fName & " = " & fvalue
if trim(fWhere) <> "" then
strSql = strSql
& " WHERE " & fWhere
end if
my_Conn.Execute strSql

next


  Nathan Bales - Romans 15:13
----------------------------------

Snitz Exchange | Do's and Dont's

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 06 April 2002 :  17:22:54  Show Profile  Visit HuwR's Homepage
strictly speaking, ifthere is no WHERE clause it should abort, it is not safe to assume they did not mean to have one, and updating your whole table by mistake is pretty disastrous, so I would not recomend your suggested fix.

Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 06 April 2002 :  17:25:03  Show Profile  Visit HuwR's Homepage
it would be better to force them to write something like 1=1 as the WHERE clause,at least that way it can't be done by accident

Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 06 April 2002 :  17:43:49  Show Profile  Visit Nathan's Homepage
If there is an offical spec somewhere then it should be changed from to reflect this.

From:
[UPDATE]                  Table Update start Tag
TEST_TABLE2 Name of Table to update
field22#'B'#TABLE_ID2 = 1 Field definitions - Format: FIELDNAME#VALUE#WHERE CLAUSE
FIELDNAME# - Name of field to be updated
VALUE# - New value for field
WHERE CLAUSE - Criteria to specify records to be updated, blank if All records
[END] End of Table Update Tag


To:
[UPDATE]                  Table Update start Tag
TEST_TABLE2 Name of Table to update
field22#'B'#TABLE_ID2 = 1 Field definitions - Format: FIELDNAME#VALUE#WHERE CLAUSE
FIELDNAME# - Name of field to be updated
VALUE# - New value for field
WHERE CLAUSE - Criteria to specify records to be updated, true if All records
[END] End of Table Update Tag


  Nathan Bales - Romans 15:13
----------------------------------

Snitz Exchange | Do's and Dont's
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 06 April 2002 :  17:46:38  Show Profile  Visit HuwR's Homepage
Since this was my mod, and was never my intention to include in the Snitz release, there has never actualy been an Official spec, and obviously my original is in error.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000 Version 3.4.07