I’ve been using Shell scripts to run some sql queries using sqlplus so far. This has worked out fine because the data was a bit too large to handle easily from within Eggplant.
But I’m starting to find a need to run a sqlplus query on the fly and use the results in some eggplant scripts. I’m sure “open process” can do this, but I need some help with the syntax.
here’s what my shell scripts look like:
#! /bin/bash
DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Applications/instantclient
export DYLD_LIBRARY_PATH
TNS_ADMIN=/Applications/instantclient
export TNS_ADMIN
PATH=$PATH:/Applications/instantclient
export PATH
sql=$(cat /EggplantShared/Lib/env) -- we have 3 different database connections depending on the testing phase, I use this to determine which one to use.
sqlplus User_Name/User_password@$sql @/Path_to_script.sql
exit
(The Path information in the above script is actually part of my .bash_profile , so I don’t know if I’m actually going to need that in here. I did for the shell scripts, but don’t if I just use terminal. )
The above example kicks off a sql query script. But i want to just run a query at that point.
One of my attempts to get this work looked like this:
set bash to "/bin/bash"
open process bash
write {{
"DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Applications/instantclient
export DYLD_LIBRARY_PATH
TNS_ADMIN=/Applications/instantclient
export TNS_ADMIN
PATH=$PATH:/Applications/instantclient
export PATH"
}} & return to process bash
write "sqlplus username/userpassword@test" & return to process bash
write "sql query goes here';" & return to process bash
write "exit" & return to process bash
read from process bash until end
put it
close process bash
when I run this, it seems to run for about 20 seconds and does not produce any results. Any ideas?
Does anyone else use sqlplus for database queries on-the-fly?
Thanks in advance.