Sponsored Content
Top Forums Shell Programming and Scripting Print statement in shell script Post 302947156 by arun888 on Tuesday 16th of June 2015 04:42:15 AM
Old 06-16-2015
I am executing a sql query from cursor through a shell script. but I am not receiving the output. when I manually triggered the query. I am receiving the output as expected.

---------- Post updated at 03:42 AM ---------- Previous update was at 02:08 AM ----------

when I executed the query through manually connecting in databse it work as below.

Code:
SQL> select /*ordered*/ distinct b.country_abbrev as country_code,DECODE(a.auto,                                                                                        'Y','DAEMON','L','LAUNCH') as sub_type,
  2          DECODE(in_use_userid,'NONE','NOT PICKED','ES','MF DAEMON','UNIX'                                                                                        ,'UNIX') AS DAEMON_TYPE,count(a.sub_idx) as sub_count
  3          FROM
  4          subiv_log a,
  5          country b
  6                  where a.sub_status_idx in (1,22,401,9)
  7                  and a.locked = 'Y'
  8                  and a.queue_flag = 'Y'
  9                  and a.auto in ('Y','L')
 10                  and a.country_idx = b.country_idx
 11          GROUP BY B.country_abbrev,A.AUTO,DECODE(in_use_userid,'NONE','NOT P                                                                                        ICKED','ES','MF DAEMON','UNIX','UNIX')
 12          ORDER BY sub_count DESC,b.country_abbrev desc ;
COUNTRY_CO SUB_TY DAEMON_TYP  SUB_COUNT
---------- ------ ---------- ----------
UK         DAEMON UNIX                7

But output is not displayed If I am running through the shell script.

The below query is executed through shell script and not getting output expected not sure whether my syntax is correct.
Code:
 
 cursor sub_cur is
        select /*ordered*/ distinct b.country_abbrev as country_code,DECODE(a.auto,'Y','DAEMON','L','LAUNCH') as sub_type,
        DECODE(in_use_userid,'NONE','NOT PICKED','ES','MF DAEMON','UNIX','UNIX') AS DAEMON_TYPE,count(a.sub_idx) as sub_count
        FROM
        subiv_log a,
        country b
                where a.sub_status_idx in (1,22,401,9)
                and a.locked = 'Y'
                and a.queue_flag = 'Y'
                and a.auto in ('Y','L')
                and a.country_idx = b.country_idx
        GROUP BY B.country_abbrev,A.AUTO,DECODE(in_use_userid,'NONE','NOT PICKED','ES','MF DAEMON','UNIX','UNIX')
        ORDER BY sub_count DESC,b.country_abbrev desc ;
 BEGIN
        dbms_output.put_line('COUNTRY_CODE'||'        '||'SUB_TYPE'||'        '||'DAEMON_TYPE'||'        '||'SUB_COUNT');

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script automation using case statement

Hi, I'm trying to write a shell script that has a menu and then dependant on the selection, will automate some samba file transfer. The problem is when I run the code without the case statement it runs fine. but when I put the case statement in the only way I can get the code to run is to... (6 Replies)
Discussion started by: ianf
6 Replies

2. Shell Programming and Scripting

Shell script not processing if statement properly

Hi I am trying to create a shell script that will look for a contracthead file first and if the contract head file does not exist on day1 exit script. Now on day2 if contracthead exists or not run the script uploading files in order such as contract line then contract contact so the... (2 Replies)
Discussion started by: jonathan184
2 Replies

3. Shell Programming and Scripting

shell script case statement

In a case statement like below : case $rental in "car") echo "For $rental Rs.20 per k/m";; "van") echo "For $rental Rs.10 per k/m";; "jeep") echo "For $rental Rs.5 per k/m";; "bicycle") echo "For $rental 20 paisa per k/m";; *) echo "Sorry, I can not gat a $rental for you";;... (4 Replies)
Discussion started by: sriram003
4 Replies

4. Shell Programming and Scripting

using SELECT sql statement in shell script

Hi there I have a database on a remote box and i have been using shell script to insert data into it for example, i could have a script that did this SN=123456 n=server1 m=x4140 sql="UPDATE main SET hostname='$n',model='$m' WHERE serial='$SN';" echo $sql |/usr/sfw/bin/mysql -h... (4 Replies)
Discussion started by: hcclnoodles
4 Replies

5. Shell Programming and Scripting

Help with IF statement with loop Shell Script

Hello I am very new to shell and I bought some books and trying to learn it. I started trying to write a script that will take a number and count it down to 1 with commas in between. This number can only be one argument. If lower than one or higher than one argument it sends an error message. ... (4 Replies)
Discussion started by: zero3ree
4 Replies

6. Shell Programming and Scripting

An issue with condition statement in shell script

Hello forum members. please go through the below mentioned issue and let me know the right solution. I have to write a script which runs another script .the executable script take input parmeters.so iam writing the the script below . Sample Code:Begins #! /bin/ksh echo " enter... (2 Replies)
Discussion started by: rajkumar_g
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

Help with if statement syntax in shell script

I want to make the file test condition a variable ($Prmshn in code below). My goal is to use something like the first three unsuccessful if statetments since the 'if #!/bin/ksh test_input() { Prmshn=${1} InFLNm=${2} ifReq="-$Prmshn $InFLNm" #the following three if statments fail: #if ] ;... (10 Replies)
Discussion started by: ms63707
10 Replies

9. Shell Programming and Scripting

Case statement in UNIX shell script

have written the below code to check whether the string received from user is a file name or dir using case statement, but its going into default case*). #!/bin/sh #Get a string from user and check whether its a existing filename or not rm str2 rm str3 echo "enter a file \c" read fil... (8 Replies)
Discussion started by: Mohan0509
8 Replies

10. 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
exit(1) 							   User Commands							   exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 08:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy