Re: DBDATE - Inside Informix 4gl
Posted in 1998
draikar@my-dejanews.com wrote: > Could you please tell me how to overwrite the date format > (which had been set in the environment variable DBDATE) > inside the Informix 4gl program? It depends on the context. Any time you explicitly convert a DATE into a string, you can use a USING "dd mmm yyyy" or similar format to obtain the format you choose, thus overriding the value of DBDATE. During INPUT etc, when a string is converted to a date, the conversion is fairly flexible anyway, and really only uses DBDATE to determine the order of the components. > Work Environment: > > Informix-4gl Ver 7.20 UD1 > OS: Sun-Solaris 2.6 > > Thanks > > -Dinesh > > P.S. I have used the "fgl_getenv()" to get an environment variable, > but I wanted to know how to set an environment inside the 4gl > program. Ah. Setting an environment variable inside a 4GL program is tricky on at least three counts. * The standard function for doing the job is putenv(), but it isn't all that standard -- ISO C doesn't standardize it; neither does POSIX. The Open Group does in Unix 98, I think. * Using putenv() correctly is more difficult than you'd think. Most of the easy ways of doing it in I4GL lead to corruption of the environment in some circumstances. * It isn't clear whether you can change DBDATE or other environment variables after they've been used and expect the change to be noted. With some variables, you can; with others, you can't -- they are 'gated' and read once and that value first read is used thereafter. There is code in the I4GL CGI kit on the IIUG web site (http://www.iiug.org) which does implement a setenv() C function, along with getenv() and putenv(), and this is usable from I4GL because it avoids the easy mistakes rather carefully. Yes, I wrote it. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>