RE: Changing value of a Informix variable
Posted in 1996
Maybe, sort of, perhaps... There are a couple of problems here. First, using putenv() isn't straight-forward. You have to give it memory that you promise not to re-use. It could be a literal string, or it can be allocated space, or it can be a global variable; it cannot be a local variable. This is because the local variable space will be reused, thus randomly changing the environment (and making it invalid to boot). Note that changing the value again leaks the first value. Second, calling putenv() may or may not affect things. Some of the Informix environment variables are read on every occasion when they are used; DBPRINT is one such, speaking from memory and assuming the code hasn't been changed since then. Others are trapped on the first occasion they are needed and not checked thereafter. I think DBDATE falls into that category, and, what's more, the code in the I4GL startup routine (fgl_init) probably makes a call which traps the value of DBDATE. That means that setting DBDATE in the program is unlikely to affect its behaviour, though it would affect child programs. There is a safer version of putenv() called setenv() in the code in the Informix CGI sample package -- pick it up from http://www.informix.com. It also documents some of the problems with the standard versions of putenv(). I wrote it. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> >From: "phr (Peter Harris)" <phr@dumbo.fmsc.com.au> >Date: Wed, 29 May 96 20:14:00 S >X-Informix-List-Id: <list.10045> > >Berton, > >Try writing a c function that calls putenv("DBDATE=whatever") and then >link that into you 4gl. Bear in mind though that when you run this >program the new DBDATE will not be available to the calling shell. > >All the best, Pete Harris > > ---------- >From: Berton Sierens >Sent: Wednesday, 29 May 1996 13:29 >Subject: Changing value of a Informix variable > >How do you change the value of let's say DBDATE from within a 4GL?