Sponsored Content
Top Forums Shell Programming and Scripting Oracle function invoked from shell script doubt Post 302950550 by arun888 on Sunday 26th of July 2015 02:51:03 PM
Old 07-26-2015
hi Jim/Vargessh,

Thanks for your help.

Location_id will be read from the text file and sales values is 10000;
Hi Gurus,

Please find my full code for my requirement and correct me if anything is wrong or any suggestion please.

Any input will be highly appreciated.

Code:
 
 
cat function.sh
sales=10000;
function_value_1(){
value_1_name=$1
value_1=`sqlplus -S /NOLOG << EOF
  CONNECT dbs/passwd@dbtod
  SET head off
  select put_valueS.$value_1_name
     (&location_id,&SALES) from dual;
  exit;
EOF`}
function_value_2(){
value_2=`sqlplus -S /NOLOG << EOF
  CONNECT dbs/passwd@dbtod
  SET head off
  select put_valueS.put_citywise_value(&location_id,&sales) from dual;
  exit;
EOF`}
function_value_3(){
value3=`sqlplus -S /NOLOG << EOF
  CONNECT dbs/passwd@dbtod
  SET head off
  select put_valueS.put_placewise_value(&location_id,&sales) from dual;
  exit;
EOF`}
function_record_delete () {
sqlplus -S /NOLOG << EOF
  CONNECT dbs/passwd@dbtod
  SET head off
SELECT value(*) INTO count_value FROM TOTAL_value WHERE location_id =&location_id AND sales =&sales;
if [[ "&count_value" >0 ]]
then
EXEC SQL DELETE FROM TOTAL_value WHERE location_id =&location_id AND sales=&sales; 
exit;
EOF}
 
while read location_id
do
  case $location_id in
    chennai|banglore)
      function_value_1 chennai_bang ;;
      function_value_1 put_area_loc_value ;;
    salem|trichy||kovai)
      function_record_delete ;;
      function_value_1 salem_trichy ;;
    tirupur)
      function_record_delete ;;
      function_value_1 tirupur ;;
    *)
      echo "location is out of the range $location_id" ;;
  esac
if [[ "$value_1" =0 ]]then
value2 ;;
value3 ;;
fi
if [[ "$value_1" =0 && "$value_2" =0 && "$value_3" =0]] then
echo"job failed"
else
echo "job sucess"
fi
done < "location.txt"

Requirement :
  1. Get the count from table for location.
  2. count > 0. trigger requested sql query.
  3. if location Chennai/banglore .. Chennai_bang function need to be called. check the value is o or 1
  4. if location salem/trichy ... salem_trichy function need to be called. check the value 0 or 1.
  5. tirupur . that function need to be triggered. check the variable value o or 1.
  6. if value is o from tat function then do check value 1 and value 2 from sql oracle.
  7. value, value 1 , value 2 is zero... trigger a message job failed.

[/code]

Last edited by rbatte1; 07-29-2015 at 05:43 AM.. Reason: Converted to LIST=1 tags from plain text
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unix + oracle doubt....involving shell script

....does the dbms_output.put_line work inside unix shell script? i mean this is to be inside the sqlplus connection as follows!! sqlplus -s $UP <<EOJ .. .. .. dbms_output.put_line ('Insertion procedure failed for UPC BC : ' || wk_key_value || ' Sqlcode: ' || SQLCODE || ' Error... (2 Replies)
Discussion started by: mexx_freedom
2 Replies

2. Shell Programming and Scripting

no shell invoked in crontab

Hi all, I am trying to run a script in crontab but I receive the email below. Note the empty variable SHELL. Apparently cron doesn't invoke a shell. That explains the errors in the script it is trying to execute. Anyone know what maybe wrong? Subject: Output from cron job... (3 Replies)
Discussion started by: ivanushka
3 Replies

3. Shell Programming and Scripting

i want to call a oracle function in my shell script

i want to call a oracle function in my shell script (4 Replies)
Discussion started by: dineshr85
4 Replies

4. Shell Programming and Scripting

shell script doubt

Hi, While reading a shell script ,i have come accross the following statements. script_name_full=$0 ***script_name=${script_name_full##*\} ***script_name_noexst=${script_name%%\.ksh} host_name=`hostname` ***host_name_short=${host_name%%\.*} can anybody tell me what is the purpose of marked... (5 Replies)
Discussion started by: ravi raj kumar
5 Replies

5. Shell Programming and Scripting

Doubt in running shell script

Hi, I'm a newbie in shell script. I have a problem in running my a.out in a bash shell script named vetri . The following is the code. #!bash/bin ./a.out abc.xyz where ./a.out is a c++ bin file and abc.xyz is an argument. My ./a.out expects an input (cin >> temp). How can I give the... (5 Replies)
Discussion started by: lchokka
5 Replies

6. Shell Programming and Scripting

shell script basic doubt

hi, I am new script learner, so my basic doubt is , how to store value of any command in a variable example $ ls | wc -l i want to stote the output of this in a variable c. so that i can use c in if else loop. and when do we use " ` " symbol in script.. can anyone also tell for... (5 Replies)
Discussion started by: hi2_t
5 Replies

7. Shell Programming and Scripting

SHELL SCRIPT Function Calling Another Function Please Help...

This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord but only one record is getting wrote in DB.... Please advise ASAP...:confused: function InsertFtg { FTGSTR="" echo "Saurabh is GREAT $#" let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies

8. Shell Programming and Scripting

Pass a variable string in To_Date Oracle function in shell script

Hello, I am trying to execute an SQL query from shell script. A part of script is something like this: fromDate=`echo $(date +"%F%T") | sed "s/-//g" | sed "s/://g"` $ORACLE_HOME/sqlplus -s /nolog <<EOD1 connect $COSDBUID/$COSDBPWD@$COSDBSID spool... (4 Replies)
Discussion started by: sanketpatel.86
4 Replies

9. Shell Programming and Scripting

How to call Oracle function with multiple arguments from shell script?

Dear All, I want to know how can i call oracle function from shell script code . My oracle function have around 5 input parameters and one return value. for name in *.csv; do echo "connecting to DB and start processing '$name' file at " echo "csv file name=$x" sqlplus -s scoot/tiger <!... (2 Replies)
Discussion started by: Balraj
2 Replies

10. Shell Programming and Scripting

Calling Oracle function from script

Hi I need to call a function in database and update the return value of that function with a value in csv file. test.csv 1,2,3,,5,,,8,9,10 1,2,3,4,5,,,8,9,10 1,2,3,,,,,8,9,10In the above file I want to replace column 2 with a value extracted from database like (select student_id from... (3 Replies)
Discussion started by: kev94
3 Replies
POSIX_SETUID(3) 							 1							   POSIX_SETUID(3)

posix_setuid - Set the UID of the current process

SYNOPSIS
bool posix_setuid (int $uid) DESCRIPTION
Set the real user ID of the current process. This is a privileged function that needs appropriate privileges (usually root) on the system to be able to perform this function. PARAMETERS
o $uid - The user id. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 posix_setuid(3) example This example will show the current user id and then set it to a different value. <?php echo posix_getuid()." "; //10001 echo posix_geteuid()." "; //10001 posix_setuid(10000); echo posix_getuid()." "; //10000 echo posix_geteuid()." "; //10000 ?> SEE ALSO
posix_setgid(3), posix_seteuid(3), posix_getuid(3), posix_geteuid(3). PHP Documentation Group POSIX_SETUID(3)
All times are GMT -4. The time now is 02:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy