Separate DBs; ++kludge;
Posted in 1991
Re "Multiple databases", Kathy Nash says "this is a bit kludgy but it
works if you're under the gun." [ sorry if I mis-quote ! ]
I'd just like to say, you ain't seen nothing yet. Try this one, an
isql shell script. Abuse and flames to the usual address, code
follows after the sig.
Cheers - Tony.
____________________________________________________________________________
Who: Tony Heskett | DHL Systems Ltd, Kings House,
How: theskett@lhr-sys.ssf-sys.dhl.com | Great West Road, Brentford, TW8 9HS
Vox: (+44) 81 747 8330 x 363 | Fax: (+44) 81 747 0875
----------------------------------------------------------------------
: # ensure /bin/sh script
# W_CLAUSE is the condition for the select statement.
# Note that the whole select statement may be a shell variable, or several.
# Also, it may be passed in as an arg (e.g. $1).
# You gotta escape the double quotes on a string comparison.
W_CLAUSE="where employee.lname matches \\"H*\\";"
# One isql writes to the named pipe, the other one reads from the pipe.
# Check if the pipe exists. If it doesn't, create it.
if [ ! -p SQLFIFO ]
then
mknod SQLFIFO p
fi
# Do the unload, database #1
# This runs asynchronously (in a sub-shell), since the pipe
# blocks after 4096 bytes (?) and the select clause may return
# more than this.
(
isql - <<!!
database attend;
unload to "SQLFIFO"
select * from employee
$W_CLAUSE;!!
)&
# Do the reload, database #2
# This runs synchronously, in the current shell.
isql - <<!!
database foobar;
load from "SQLFIFO"
insert into employee;!!