Re: ISQL & Multiple Problem
Posted in 1996
Don, :-) :-) I have a trouble with this concept of programming using ISQL (feb 94) :-) I try to use values of data fields (integer) to be multiple together to print :-) the answer. :-) Here what I did... :-) :-) database :-) . :-) snip :-) . :-) select :-) tablea.fielda, :-) tablea.fieldb :-) from tablea :-) end :-) . :-) snip :-) . :-) on every row :-) print column x, fielda * fieldb usning "#####&", :-) . :-) snip :-) :-) Thanks in advance! :-) Don Poole :-) A couple of things spring to mind... a) You might need brackets around the multiplication, eg (fielda * fieldb) using ...... (I assume 'usning' is just a typo in the mail message :->) b) It may sound obvious, but check that both columns are numeric (integer, smallint, decimal, float, smallfloat, etc). Char columns cannot have mathematical operations performed on them, even if they only contain numerical values. c) Do both columns contain a value in every row selected. When you try and multiply two columns (or add, subtract, etc) the result will be null if ANY column involved is null. If any of the values are null, and this is correct, you can either exclude these in the select statement: ... where (fielda is not null and fieldb is not null) ... or you can use variables to do the multiplication: ... define vara int varb int printvar int end ... on every row if (fielda is not null and fieldb is not null) then begin let vara = fielda let varb = fieldb let printvar = (vara * varb) end else if fielda is null then let printvar = fieldb if fieldb is null then let printvar = fielda print column x, printvar using ... (This doesn't account for rows where both fielda and fieldb are null - not sure what you would want to do with these). HTH, Cheers, Richard. ----------------------------------------------------------------- | _________ | Richard Thomas | | / /_______| | r.thomas@csl.gov.uk | | / /__/ | | | /_/ | TRIGGER happy ;-) | | | | -----------------------------------------------------------------