This is a discussion on Need to create my own environment variable in Informix within the Informix forums, part of the Database Server Software category; --> Hi, I am using Informix 7.2 on a AIX box and I have a peculiar need, in my project ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I am using Informix 7.2 on a AIX box and I have a peculiar need, in my project we are working on a installing triggers for all the clients, but a part of these triggers need to be inactive for some clients and active for others. The trigger gives additional functionality that many clients do not require. I cannot use global variables as they are session dependent and I cannot use tables because it will slow down the server with thousands of transactions hitting the trigger. I also thought about using memory resident table for this purpose but it is again very slow cause its a transactional system and the client doesn't want any degradation in performance. Is there any way of creating a TRUE global variable that initializes with the database and retains its status throughout all sessions. like environmental variables. or is there any other way you ppl would recommend. Thanks again for all the help. Regards, Aash sending to informix-list |
| ||||
| By clients do you mean connecting clients or customers? If you mean different customers then... Use m4 or cpp to preprocess the sql that creates the triggers. 1. Have two directory ../triggers/released and ../triggers/active 2. In the released directory have a single sql file per trigger named after the trigger that includes #include <../triggers/active/actconfig.h> (or .inc) #ifdef X_on then do extra code #endif 2. For the first release copy released/config.h to active/actconfig.h then edit this file to switch on/off features for your customer. Subsequent code releases do not overwrite the active directory or the active config file! 3. Then for each file in the released directory preprocess it into the active directory. 4. If you need to change something then update .../triggers/active/actconfig.h to change the switches and repreprocess everything. 5.. When you release new triggers your source code control system should update the released directory. Then you merge any new config options in released/config.h into active/actconfig.h and repreprocess everything. 6. To update the triggers cd into the active directory and run upload.sh <database>:- DB=$1 # Create drop triggers script. for SQL in *.sql do TRIGNAME=`basename $SQL .sql` echo "drop trigger $TRIGNAM;" done >dropall.run # Drop all triggers dbaccess $DB < ${DB}.dropall.run > ${DB}.dropall.out 2>&1 # Run all sqls to create triggers. for SQL in ../active/*.sql do TRIGNAME=`basename $SQL .sql` LOGFILE=${TRIGNAME}.log dbaccess $DB < $SQL > ${DB}.$LOGFILE 2>&1 done Then check *.log and *.out for errors! Note 1. All output starts with $DB. so you can search it easily. 2. The dropall script does not end in .sql or .log so it will not be overwritten by the create scripts. 3. All the sql is in the active directory so it is easy to see what was run. 4. Nothing is evaluated at runtime so no performance hit! 5. New releases do not overwrite the active directory nor the active config file. Easy! David. |