Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Pass value back to unix variable Post 302583821 by wtolentino on Wednesday 21st of December 2011 10:10:33 AM
Old 12-21-2011
Pass value back to unix variable

i had this unix korn shell code that connects to oracle database and execute the oracle procedure. i need to add a variable that indicates the oracle procedure failed. basically the variable is to check if the oracle procedure failed it will assign 1 and when the variable is equal to 1 it will not move the files.

below is the code snipet.

Code:
NUMFILES=`ls -1 *.* | wc -l`
 if (( ${NUMFILES} == 0 )); then
   echo "WARNING: There are no files in process directory.\n" >> $LOG_FILE
   exit 1
 fi
#
 for filename in $(ls -1 *.*)
 do
  echo "Processing $filename \n" >> $LOG_FILE
  #
  echo "Executed PL/SQL package for $filename\n" >> $LOG_FILE
  SQL_LOG_FILE=${LOG_DIR}/${filename}_${LOGDATE}.log
  DB_RSLT=`sqlplus -s <<EOF >> $SQL_LOG_FILE >> $LOG_FILE
   $USERID
   set serveroutput on size 999999;
   declare
    v_result varchar2(200);
   begin
    $sql_error=0                                             <-- i tried to add this and there was an error
    bdms_app.pa_bdms_upload_load_rating.upload('$filename');
   exception
    when others then
     $sql_error=1;                                           <-- i tried to add this and there was an error
   end;
/ 
   set serveroutput off;
   exit 0
  EOF`
  wait
  #
  RC=$?
  #
  echo $DB_RSLT >> $LOG_FILE
  echo "$filename \n" >> $RATING_LOG
  #
  if (( $sql_error == 0 )); then                             <-- if the variable is equal to 0 proceed to moving the file
    echo "Copied $filename to $ARCHIVE_DIR\n" >> $LOG_FILE
    cp $filename $ARCHIVE_DIR
    echo "Delete $filename from $INPUT_DIR\n" >> $LOG_FILE
    rm -f $filename
  fi
  #
 done
 echo "End of Step 2\n" >> $LOG_FILE

this is the error that i am getting.
Code:
******************************
Run date: 12/21/2011 09:57:36
     
Step 1 Check for files to process
files to process        2

End of Step 1

Step 2 Process the files

Processing asd.csv 

Executed PL/SQL package for asd.csv

    =0
    *
ERROR at line 4:
ORA-06550: line 4, column 5:
PLS-00103: Encountered the symbol "=" when expecting one of the following:
begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe

thank you.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

pass parameter back to calling program

Hi all, I am running AIX version 4. I have a shell script that is calling another script. I want the called script to obtain a value and pass it back to the calling script. So far, I know that to pass a parameter to a called script is as such: sh proc2.sh $1 $2 etc. What I don't know how... (11 Replies)
Discussion started by: jthomas
11 Replies

2. UNIX for Dummies Questions & Answers

How to pass a oracle variable back to the shell script

Hi, I am calling an oracle function that returns a number (either 0 or 2), how do I pass that pass to the wrapping shell script as I would like to do other things based on the value returned by the oracle function. Your help will be appreciated. -------------------------- sqlplus / <<... (3 Replies)
Discussion started by: Jtrinh
3 Replies

3. UNIX for Advanced & Expert Users

How to pass unix variable to SQLPLUS

hi fellows, can any body tell me how to pass unix variables to oracle code is... #! /bin/ksh echo ENTER DATE VALUE's read START_DATE END_DATE sqlplus xyx/abc@oracle select * from table1 where coloumn1 between $START_DATE and $END_DATE; is this is correct way........... Thanks in... (1 Reply)
Discussion started by: chiru
1 Replies

4. UNIX for Dummies Questions & Answers

How to pass unix variable to oracle

hi , how to pass unix variable to oracle code is ............. #! /bin/ksh echo enter date vale read date1 sqlplus x/y@oracle select * from emp where statrt_date= $date1 is this is correct way... (1 Reply)
Discussion started by: chiru
1 Replies

5. Solaris

How to use Secure Shell (SSH) to pass results back to invoking machine

Hi, I am running a script from a client machine X which does "SSH" to around 100 other machines in a farm and invokes a local script on each of those machines. Local script localscript.sh on each of those 100 target machines, does some machine specific function like fetch the specific machine's... (1 Reply)
Discussion started by: waavman
1 Replies

6. Shell Programming and Scripting

Is it possible to pass variable from awk to shell back

I am passing a varaible to from Shell to awk then I am doing some maniplation for that variable inside awk. I want that maniplated variable value back to shell , Is this possible .Please let me know. (12 Replies)
Discussion started by: unishiva
12 Replies

7. AIX

back to back printing in UNIX

Hi , Can you suggest me how to back to back printing in UNIX? Is there any way? Kindly advise. Regards Vijaya Amirtha Raj (3 Replies)
Discussion started by: amirthraj_12
3 Replies

8. Red Hat

How to pass value of pwd as variable in SED to replace variable in a script file

Hi all, Hereby wish to have your advise for below: Main concept is I intend to get current directory of my script file. This script file will be copied to /etc/init.d. A string in this copy will be replaced with current directory value. Below is original script file: ... (6 Replies)
Discussion started by: cielle
6 Replies

9. Shell Programming and Scripting

Pass back return code for file delete failure

Hello Experts, This script to delete a file is submitted from an SAP system which has 2 servers. When it happens to run on server 1, the delete is successful. When it runs on server 2, the delete always fails. All user accounts and permissions have been adjusted to match on both servers. Is it... (5 Replies)
Discussion started by: SAPDEVEL
5 Replies

10. Shell Programming and Scripting

Need to pass Oracle SQL output to Linux and back... Help!

Hi all, Hopefully you can help. This is what I'm trying to achieve: Obtain a list of usernames out of an Oracle Database Based on this list, link each username with an Oracle Internet Directory (OID) GUID Using the username and GUID perform a database update for all users Here are the... (7 Replies)
Discussion started by: exm
7 Replies
line(1) 						      General Commands Manual							   line(1)

NAME
line - Reads one line from standard input SYNOPSIS
line STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: line: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
None DESCRIPTION
The line command copies one line, up to and including a newline, from standard input and writes it to standard output. Use this command within a shell command file to read from your terminal. The line command always writes at least a newline character. NOTES
The line utility has no internationalization features and is marked LEGACY in XCU Issue 5. Use the read utility instead. EXIT STATUS
Success. End-of-File. EXAMPLES
To read a line from the keyboard and append it to a file, enter: echo 'Enter comments for the log:' echo ': c' line >>log This shell procedure displays the message: Enter comments for the log: It then reads a line of text from the keyboard and adds it to the end of the file log. The echo ': c' command displays a : (colon) prompt. See the echo command for information about the c escape sequence. SEE ALSO
Commands: echo(1), ksh(1), read(1), Bourne shell sh(1b), POSIX shell sh(1p) Functions: read(2) Standards: standards(5) line(1)
All times are GMT -4. The time now is 03:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy