Re: Type decimal
Posted in 1998
On Thu, 8 Jan 1998, Manel Falco wrote: > I have a table with a type column decimal(8). In this column I want to > put a several of numbers with variable decimal numbers like: > > 24.54, 78.382, 124.39294 > > the decimal(8) is very useful for that but when I want to get them > by select or cursor into a variable, the values are rounded to 2 decimals. Why? What makes you think that they are rounded to 2 decimals? In my experience, there is no problem whatsoever with the fetched data, but there frequently are problems with the way it is formatted for printing. You should try using rfmtdec() from the ESQL/C library with a format such as "-##&.&&&&&" to print the data you show -- it should show all the decimal places you need. There is also code in the SQLCMD program (at the IIUG web site, http://www.iiug.org) in decsci.c which does a reasonable job of formatting decimals, including scientific notation (eg 1.2439294E-39 or 1.2439294E39); if you use that code and find that you are still getting rounded data, then I want to see what your code looks like. You could also try the dump_decimal() routine to see exactly what the data in the decimal structure is -- that's in dumpdec.ec in the SQLCMD package. Although you can declare ESQL/C variables as '$ decimal(8,2) value;', I don't see anything in the generated code which indicates the decimal precision is enforced -- the information simply isn't made available to the runtime libraries. Yours, Jonathan Leffler (johnl@informix.com) #include <witticism.h>