extracting value of select(count) in the API
Posted in 2004
Topics: Data Types & Schema Design
Hi, I'm trying to access the value of select(count) in an API program, passing this query to mi_exec. It's not an integer, as I retrieve the wrong value. Its type may be a varchar but converting the varchar to a string doesn't seem to print the correct value. Thanks, Steven
what version of the engine/sdk etc??? I'd guess it's returning a decimal/float of some description try casting it to an int in the sql Steven Kurlander wrote: > > Hi, > > I'm trying to access the value of select(count) in an API program, > passing this query to mi_exec. It's not an integer, as I retrieve the > wrong value. Its type may be a varchar but converting the varchar to > a string doesn't seem to print the correct value. > > Thanks, > Steven -- Paul Watson # Oninit Ltd # Growing old is mandatory Tel: +44 1436 672201 # Growing up is optional Fax: +44 1436 678693 # Mob: +44 7818 003457 # www.oninit.com #
On Fri, 23 Jan 2004 08:58:24 -0500, Steven Kurlander wrote:
> Hi,
>
> I'm trying to access the value of select(count) in an API program, passing
> this query to mi_exec. It's not an integer, as I retrieve the wrong value.
> Its type may be a varchar but converting the varchar to a string doesn't
> seem to print the correct value.
Steven,
All versions of IDS beginning with 6.0 return DECIMAL type for numeric
aggregates, that is the problem. If you BIND the column to an integer host
variable the engine SHOULD make the conversion automatically assuming the
value does not overflow since DECIMAL supports up to 32digits and INTEGER only
9.2 digits (ie not quite 10) of decimal precision. If you must have a 'C'
datatype and integer is too small you can use double to get up to 15+ digits.
You do not specify, but if you are using IDS 9.xx you can use explicit
conversions (not supported in 7.xx) in your SELECT also:
SELECT COUNT(*) :: INT
FROM ...
Art S. Kagel