Unix Technical Forum

Need to create my own environment variable in Informix

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 ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 10:50 AM
Aashish Ramsinghani - ASDC, Chennai
 
Posts: n/a
Default Need to create my own environment variable in Informix


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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 10:50 AM
david@smooth1.co.uk
 
Posts: n/a
Default Re: Need to create my own environment variable in Informix


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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:40 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com