Re: ESQL/C incvfmtasc() problem
Posted in 1996
The fractions bit always requires a decimal point. Use: if ( incvfmtasc(".1", "%F5", &moment) < 0 ) I don't know why, but that's the way it is. If you are using %F in the output formatting, you don't supply the decimal point yourself -- it does it for you. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> }From: gregf@mailhub.tfs.com (Greg Faulk) }Date: 3 Oct 1996 23:15:40 GMT }X-Informix-List-Id: <news.28856> } }I'm having trouble setting the FRACTION component of an Informix Interval }datatype column using the incvfmtasc() function. I can set HOURS, MINUTES }and SECONDS successfully but the FRACTION always yields an error. I've }worked up a small example. If anyone can see what I'm doing wrong I'd }appreciate the help. } }-----------snip--------------- } }#include <stdio.h> } }EXEC SQL include datetime; } }main() }{ } char out_str[30]; } EXEC SQL BEGIN DECLARE SECTION; } interval hour to fraction(5) moment; } EXEC SQL END DECLARE SECTION; } } /* } * Set seconds. This case works OK. } */ } if ( incvfmtasc("1", "%S", &moment) < 0 ) { } printf("failed case 1\\n"); } } else { } printf("succeded case 1\\n"); } intoasc(&moment, out_str); } printf("Interval value = %s\\n", out_str); } } } } /* } * This case fails. } */ } if ( incvfmtasc("1", "%F", &moment) < 0 ) { } printf("\\nfailed case 2\\n"); } } else { } printf("\\nsucceded case 2\\n"); } intoasc(&moment, out_str); } printf("Interval value = %s\\n", out_str); } } } } /* } * This case fails. } */ } if ( incvfmtasc("1", "%F5", &moment) < 0 ) { } printf("\\nfailed case 3\\n"); } } else { } printf("\\nsucceded case 3\\n"); } intoasc(&moment, out_str); } printf("Interval value = %s\\n", out_str); } } }} } }-- }Greg C. Faulk Database Administrator }TRW Enterprise Solutions Phone: (510) 645-3655 }300 Lakeside Drive Fax: (510) 645-3020 }Oakland CA 94612-3540 E-mail: gregf@tfs.com }-- }Greg C. Faulk Database Administrator }TRW Enterprise Solutions Phone: (510) 645-3655 }300 Lakeside Drive Fax: (510) 645-3020 }