if statement in shell is not getting fired?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers if statement in shell is not getting fired?
# 1  
Old 11-21-2011
Question if statement in shell is not getting fired?

Hi,
When i am executing the shell script, i am unable to get the dates values substituted for variables &mtd and &wsd.
Please let me know where i am going wrong and please let me know how to get the values of these variables.
I have tried all methods but the if condition is getting fired twice or is not getting recognise and getting statement ignored.
Code:
#!/bin/ksh -x

SOURCE_NAME="$1"

if [ $SOURCE_NAME = "ss" ] 
then
# recursive call for all us_stars sub sources
        $PCR_HOME/bin/update_load_status_dly.sh ss
fi

LOAD_TABLE_NAME=""
WHERE_CLAUSE="where TRADE_DATE= "

case $SOURCE_NAME in
aa) LOAD_TABLE_NAME="aa_TRADE_DLY";;

*)     exit 0;;
esac


sqlplus -s $user/$PASSWORD$ORACLE_SID <<END

       col cd new_value wsd noprint
       col md new_value mtd noprint

DECLARE

BEGIN
       select to_char(max(week_start_date),'dd-mon-yyyy') cd
       from temp
       where run_type='DAILY'
       and loading_stage=0;

       select to_char(max(week_start_date),'dd-mon-yyyy') md
       from temp
       where run_type='DAILY'
       and loading_stage=0;

       if (pcrstage.is_str_source ($SOURCE_NAME))
       then
       update table1 s
       set record_count = record_count + (select count(*)
                     from $LOAD_TABLE_NAME  $WHERE_CLAUSE to_date       ('&mtd','dd-mon-yyyy'))
       where run_type='DAILY'
       and loading_stage=0
       and source='$SOURCE_NAME'
       and week_start_date=to_date('&wsd','dd-mon-yyyy');
       
        else
       update temp1 s
       set record_count = (select count(*)
                     from $LOAD_TABLE_NAME  $WHERE_CLAUSE to_date('&mtd','dd-mon-yyyy'))
       where run_type='DAILY'
       and loading_stage=0
       and source='$SOURCE_NAME'
       and week_start_date=to_date('&wsd','dd-mon-yyyy');
       end if;

       commit;
END;
       
END
       
exit;


Last edited by Scott; 11-21-2011 at 05:13 AM.. Reason: Code tags...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If statement in a shell script

Please see part of a shell script below. #Move folder to HOT folder echo " moving $PRE_OCR_DIR/$BATCHNAME to $HOT_FOLDER_DIR\n" #chmod -R 777 $PRE_OCR_DIR/$BATCHNAME mv $PRE_OCR_DIR/$BATCHNAME $HOT_FOLDER_DIR I wish to write an if statement around the move that if that if $BATCHNAME... (3 Replies)
Discussion started by: worky
3 Replies

2. Shell Programming and Scripting

Using shell to generate case statement

Hi Gurus, I have a very weird requirement and have no clue to resolve the issue. please help me get out this difficulty below two tables, table1 contains the column name. D means this column used for the rule. for example: rule 0 is all columns have value, rule1 is col3 and col7 have no value.... (2 Replies)
Discussion started by: Torhong
2 Replies

3. Shell Programming and Scripting

Print statement in shell script

Hi All, when I executed the query in normal unix mode, the output is expected. if I executed the query using shell script, I am not getting the result. not sure whether I need to use dbms_output.put_line or echo. dbms_output.put_line("COUNTRY_CODE"||" "||"SUB_TYPE"||" ... (3 Replies)
Discussion started by: arun888
3 Replies

4. Shell Programming and Scripting

This find command could have got me fired

Oracle Linux 6.4/Bash shell I am not an expert in find command I wanted to delete all files with extension .dmp which are older than 60 days. So I executed rm command from within find as show below and it deleted ALL THE FILES (even files without any extention) which the user had permission... (4 Replies)
Discussion started by: John K
4 Replies

5. Shell Programming and Scripting

shell programming if statement help

Hello i am trying to change every word that starts with "a" or "b" . if it starts with one of the letters i want to add xx rho the end of the word. Example : boy ==> boyxx that what i did so far #!/bin/ksh echo "please enter a word: " read word if || ; then echo "the word is... (6 Replies)
Discussion started by: koricha
6 Replies

6. Shell Programming and Scripting

Conditional Shell Statement

I want to add a conditional statement to a user's .profile file. I have a certain number of users that log in and use the rksh (Restricted Korn Shell). When they log in, it starts a certain program and when they exit this program, the system logs them out. When they are in this program, they can... (2 Replies)
Discussion started by: rjulich
2 Replies

7. Shell Programming and Scripting

If then Else statement in shell script

Hi, I am having a shell Script which i need to modify. I am new to shell scripting , needs help. The Logic which needs to be incorporated is as follows :- The script need to check the length of first Line in a data fine and of the length of the file is > 130 then validated the input... (2 Replies)
Discussion started by: mvichare
2 Replies

8. Shell Programming and Scripting

Shell case statement

echo -e "Select: \c" read IN pattern="1-20" case $IN in ) echo "Selected: $IN" ;; *) echo "Invalid selection: $IN" ;; esac # sh test Select: 10 Invalid selection: 10 # sh test Select: 2 (6 Replies)
Discussion started by: Ikon
6 Replies

9. Shell Programming and Scripting

put a shell in for statement

I'm a newbie here, today I've got a problem. Here's the shell: b.sh #!/bin/bash rm -rf $1 a.sh #!/bin/bash for file in '/root/Desktop/test/*' do echo $file sh ./b.sh $file done ls /root/Desktop/test When I sh a.sh, the result is : (2 Replies)
Discussion started by: very.very.sorry
2 Replies

10. UNIX for Advanced & Expert Users

Read the entire output fired by ps command

Actually I want to display the entire output fired by ps command. My output gets trucated after 80 chars. Thus, i am not able to see the entire command running when i give a ps -eaf .... Does anyone know how do i display the entire output fired by ps command .. (i.e the command along with... (5 Replies)
Discussion started by: vinithepoo
5 Replies
Login or Register to Ask a Question