Output is not comming as expected


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Output is not comming as expected
# 8  
Old 03-26-2012
I suggest create the sql file and .sh file seprated and call the sql file in .sh file and schedule in crontab for desired time , I'm using the same..

eg:-

user.sh:
Code:
ORACLE_HOME=/app/oracle/product/10.0.0.0
export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH
export PATH
CDATE=`date +%d%m%Y`
export CDATE
echo $CDATE
. /home/oracle/.bash_profile
sqlplus abc_USER/password@abcd.pfizer.com  @/home/oracle/script/user.sql


user.sql:
clear breaks
clear columns
clear compute
set pagesize 50000
set NEWPAGE 1
set linesize 32767
set colsep ,
set headsep on
set serveroutput on size 1000000 format wrap
set feedback off
set underline off
SPOOL user.csv
select USERNAME, EMAIL, FULL_NAME, LAST_LOGIN, DATE,CREATED from sfuser where (trunc(sysdate) -trunc(Last_login))>120 and status = 'Active'
and username not in (select username from scm_authorized_keys)
and ID not in (SELECT distinct created_by_id FROM audit_entry WHERE (TRUNC(SYSDATE) -TRUNC(date_created)) < 120);
SPOOL OFF

Moderator's Comments:
Mod Comment Please use next time code tags for your code and data

Last edited by methyl; 03-26-2012 at 09:29 AM.. Reason: separate Shell script from Oracle sql
Mohammed Fareed
# 9  
Old 03-26-2012
I have given input output example below!

---------- Post updated at 06:44 AM ---------- Previous update was at 06:33 AM ----------

Could you pls temme way to create SQL file? Becoz.. whatever i am familiar with is that.. we need to install some packages before creating it.

If it is working then it would be good for me to go with the same. Becoz its just the basic script.. Going ahead.. i need to make give timer to execute this script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep output to file result not as expected

Hi Gurus, I run command grep ABC file1 > file2 against below file. I got all ABC_xxx in one line in file2. I expect to get multiple lines in file2. If I print result in screen, the result is expected. thanks in advance My os is SunOS 5.10 Generic_150400-64 sun4v sparc sun4v ABC_123 XXXXX... (2 Replies)
Discussion started by: green_k
2 Replies

2. Shell Programming and Scripting

awk not giving the output expected

Hello, I am practising awk and decided to compare two columns and print the result of the comparison as third column i/p data c1,c2,c3 1,a,b 1,b,b i am trying to compare the last two columns and if they match I am trying to print match else mismatch(Ideally i want that as a last column... (5 Replies)
Discussion started by: mkathi
5 Replies

3. Shell Programming and Scripting

For loop not giving expected output

#cat /tmp/input old_array old_dev new_dev new_array 0577 008AB 01744 0125 0577 008AC 01745 0125 0577 008AD 005C8 0125 0577 008AE 005C9 0125 0577 008AF 005CA 0125 0577 008B0 005CB 0125 0577 008B1 005CC 0125 cat test.sh #!/bin/ksh... (4 Replies)
Discussion started by: mbak
4 Replies

4. Shell Programming and Scripting

awk output not what was expected

Good Moring, I am currently reading about awk in a manual and following the examples using the oratab file. My system is SOLARIS 10 I think I am getting strange behavior judging by what the book says to do and what I am getting with my little program. Here is my program: grep -v oratab |... (4 Replies)
Discussion started by: bdby
4 Replies

5. Shell Programming and Scripting

Grep can't match expected but output all

lyang001@lyang001-OptiPlex-9010:~$ service --status-all |grep dbus acpid acpi-support alsa-restore alsa-store anacron apport atd avahi-daemon bluetooth cgroup-lite console-setup cron cups dbus dmesg dns-clean failsafe-x ... (1 Reply)
Discussion started by: yanglei_fage
1 Replies

6. Shell Programming and Scripting

Trying to learn to use functions in gawk and not getting expected output.

I've been working on improving my awk, and the next thing I want to learn is to properly use functions (I understand functions in shell and python). I have the following code which includes how I did this without functions before, and two attempts I've made to do it with functions: function... (3 Replies)
Discussion started by: DeCoTwc
3 Replies

7. Shell Programming and Scripting

awk - output comming strange: for operator ~ and == .

Hi awk experts, I am getting a strange output , may be it is normal but I am unable to comprehend, When Using == operator it is showing correct: # ls -l | awk '{for (i=0;i<=NF;i++) if ( $i =="info" )print $1,$6,$7,$8,$9}' drwx------ Jan 17 10:44 info But When using ~ (equal )... (4 Replies)
Discussion started by: rveri
4 Replies

8. Shell Programming and Scripting

Not getting expected output

Hi I have written below script to get the data in table form. #!/bin/sh echo "File Name\tType" for i in *; do echo "$i\t\c" if ; then echo "directory" elif ; then echo "symbolic link" elif ; then echo "file" else echo "unknown" fi donehowever i am getting output in different way... (3 Replies)
Discussion started by: scriptor
3 Replies

9. Shell Programming and Scripting

awk not generating the expected output

Hi, I am presently stuck in a csv file. INPUT CSV baseball,NULL,8798765,Most played baseball,NULL,8928192,Most played baseball,NULL,5678945,Most played cricket,NOTNULL,125782,Usually played cricket,NOTNULL,678921,Usually played EXPECTED OUTPUT CSV ... (7 Replies)
Discussion started by: scripter12
7 Replies

10. Shell Programming and Scripting

scripting/awk help : awk sum output is not comming in regular format. Pls advise.

Hi Experts, I am adding a column of numbers with awk , however not getting correct output: # awk '{sum+=$1} END {print sum}' datafile 2.15291e+06 How can I getthe output like : 2152910 Thank you.. # awk '{sum+=$1} END {print sum}' datafile 2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies
Login or Register to Ask a Question