I have a table named “GEOMETRY” which looks like this
Create Table geometry (
keyValue Integer,
control_id Integer,
PropertyName text Collate Nocase,
PropertyValue text)
propertyName field has one of the following values “LEFT”,“TOP”,“WIDTH”,“HEIGHT” …
propertyVALUE is well, the value of the property (it is TEXT as there are other related tables with similar structure that do not have numeric values)
What I need to do is to take all those values for a given keyValue
multiply it by a constant value, and update the values for another keyValue
The SQL I created (yeah, not a prepared statement)… works, generates no errors, but sets the destination values to NULL
SQL= _
"UPDATE geometry "+_
" SET propertyvalue=("+_
" SELECT ROUND(CAST(propertyValue AS Double)*"+Str(hmult)+",1)"+_
" FROM geometry b"+_
" WHERE b.keyValue = "+Str(from_keyValue) + _
" AND b.control_id = "+Str(ctrl_ID)+ _
" AND b.propertyname in('left','width')" +_
")"+_
"WHERE keyValue = "+Str(to_keyValue)+ _
" AND control_id = "+Str(ctrl_ID)+ _
" AND propertyname in('left','width')"
Ctrl_ID is which single control is to be updated
From_keyValue is the key pointing to the BASELINE coordinate system
To_keyValue is the key pointing to the record to be updated
hmult is a value that was precalcuated
I know that Geometry is correct BEFORE this SQL runs
If I execute just the subquery, it returns the correct values
hMult is a valid value, as a matter of fact if I examine the generated SQL it looks just fine
It does not create an exception (it when I do the DB_EXECUTE, no error is generated)
HOWEVER, all the records that should be affected now have NULL in propertyValue
There is another query, where the ONLY difference is vMult instead of hMult
and “top”,“width” instead of “left”,“width”
Does anyone see some amiss? I have been beating my head on this for most of the day