oracle - Return value from sql script to shell script -


i have shell script calls following sql script:

     insert semantic.count_statistics (...);      update semantic.count_statistics       set prnct_change = 1.1;     --want store result of bellow select statement in model_count variable        select prnct_change       semantic.count_statistics       model = '&my_model'       , new_date = (                       select max(new_date)                       semantic.count_statistics                       model = '&my_model'                      ); 

now, how return percentage_number variable shell script?

my shell script follows:

#!/bin/bash # # setup oracle, java, , d2rq environment . /etc/profile.d/oracle.sh . /etc/profile.d/java.sh . /etc/profile.d/d2rq.sh  cd /opt/d2rq  model_count=$(sqlplus user/pass @count.sql 'model')  if ["$model_count" > 0];    echo "percentage count positive" else    echo "its negative" 

i last select statement result stored model_count variable in shell script.

anyone knows why not working?

a bash example use of bash-function (note! database os-authentication "/")

#!/bin/bash  get_count () {     sqlplus -s / <<!     set heading off     set feedback off     set pages 0     select count(*) all_objects object_type = '$1';  ! }  count=$(get_count $1)  echo $count  if [ "$count" -gt 0 ];     echo "is greater zero" else     echo "is less or equal zero" fi   ~/tmp/ $ ./count.sh index 2922 greater 0 ~/tmp/ $ ./count.sh table 1911 greater 0 ~/tmp/ $ ./count.sh function 226 greater 0 ~/tmp/ $ ./count.sh "superobject" 0 less or equal 0 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -