Need to write shell script for my .sql file call


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to write shell script for my .sql file call
# 1  
Old 12-11-2013
Need to write shell script for my .sql file call

Hi Guys,

I need to write a simple shell script which will generate a .csv file/report by calling .sql file inside a shell script.

Can somebody help me on this.

Thanks in advance!

Regards,
LK
# 2  
Old 12-11-2013
So have you tried anything so far? If yes, where are you stuck?
# 3  
Old 12-11-2013
No..I am new to unix. but I need to understand on shell script and Once I run shell script by calling .sql file it generates .csv report. then i need to send a mail with .csv file attachment to one of the recipient.

Could you help me on this. I appreciate your response!
# 4  
Old 12-11-2013
Here is an example:
Code:
sqlplus -s username/password@instance << EOF
set echo off head off feed off pagesize 0 trimspool on linesize 1000 colsep ,
spool output.csv
@yoursqlfile
spool off;
exit;
EOF

mailx -s "Subject" user@domain.com < output.csv

# 5  
Old 12-12-2013
Is this code can save it as shell script and shall I schedule it?
# 6  
Old 12-12-2013
Quote:
Originally Posted by lakshmanraok117
Is this code can save it as shell script and shall I schedule it?
Of course yes. You can save it as shell script and can schedule it.
# 7  
Old 12-12-2013
How to send an email in unix with my .csv file attachment

Hi Guys,
How to send an email in unix with myfile.csv attachment. myfile.csv is in unix path.

I have used the below command, but its sending .csv data in mail body.

mailx -s "Subject" user@domain.com < output.csv

Can any one suggest me plz..

Regards,
LKR
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Not able to write SQL query output in to .csv file with shell script.

I am trying to write SQL query output into a .csv file. But in the output columns are displaying in different lines instead of coming in one line. Main Code shell script: this is my code: #!/bin/bash file="db_detail.txt" . $file rm /batch/corpplan/bin/dan.csv... (6 Replies)
Discussion started by: sandeepgoli53
6 Replies

2. Shell Programming and Scripting

Shell script to call sql file

hi , the below script contains sql query and after executed it sends the output of the query (output.txt) to an email body with conditional subject line based on the output of all_counts_match.txt. i want to make this script generic so that it can accept the sql file as parameter and can... (5 Replies)
Discussion started by: itzkashi
5 Replies

3. Shell Programming and Scripting

Need help to write to log file whether the shell script call pass fail

I have the below script triggered daily at 330am in the morning, since last 7 days job not writing anything to database. below impala shell calling shell file which has sql , it is extracting data and loads to a flat file txt file. which is going wrong for last 1 week. need help, echo... (2 Replies)
Discussion started by: cplusplus1
2 Replies

4. Shell Programming and Scripting

How to call SQL Loader in shell script?

HI Experts, I am pretty new to scripting and i need to create a perl or shell script which should fetch a file from local directory and insert the data into a table using sql loader. This will be later added to chron job to run daily and fetch all files and load them into the table. Also i... (1 Reply)
Discussion started by: sam1234
1 Replies

5. Shell Programming and Scripting

Need Help: Shell script to call sql session with variables stored in .txt file

Hi, I need help in writing a shell script which can read data from a text file (Cancel_ID.txt) and then calls sqlplus session (Cancel.sql) with the first line parameter of the text file ("0322600453") till all rows are not completed. ... (4 Replies)
Discussion started by: Khan28
4 Replies

6. UNIX for Advanced & Expert Users

call sql through shell script

Hi i am not able to connect sqlplus my script is as follows $ORACLE_HOME/bin/sqlplus << ! > /tmp/extract/DM.txt and output is SQL*Plus: Release 11.1.0.7.0 - Production on Wed Jan 18 02:53:54 2012 Copyright (c) 1982, 2008, Oracle. All rights reserved. Enter user-name: t175481... (1 Reply)
Discussion started by: tushar_spatil
1 Replies

7. Shell Programming and Scripting

call shell script from pl/sql block

Hi Experts, I want to call script_name.ksh as many time as id in customer table and also pass it as a parameter to script. someting Like below. for i in select id from customer do ./script_name.ksh $i & done I have figured out how to have ID from customer but now how to call... (3 Replies)
Discussion started by: Opamps123
3 Replies

8. Shell Programming and Scripting

how to call shell script from pl/sql loop

Hello, I am doing a shell script which contain a pl/sql loop to search for 3 values, i would like to call another shell script inside this sql loop each time it find the values. so how can i call shell script from pl/sql using its variables, any idea? Here is idea about the code: my... (1 Reply)
Discussion started by: rosalinda
1 Replies

9. Shell Programming and Scripting

how can i call a shell script from pl/sql

I would like to call the shell script from pl/sql and i need to uses the value returned by the shell script in pl/sql procedure. can any one suggest me how can i do that? (3 Replies)
Discussion started by: rajesh.P
3 Replies

10. UNIX for Dummies Questions & Answers

how can a call shell script from pl/sql

I like to call a shell script from pl/sql proceduere and i have to use the shell script return value in that procedure. i am using oracle 9i and cygwin. can any one suggest me how can i do this (0 Replies)
Discussion started by: rajesh.P
0 Replies
Login or Register to Ask a Question