Sponsored Content
Full Discussion: SQL Report from UNIX
Top Forums UNIX for Dummies Questions & Answers SQL Report from UNIX Post 302920402 by vbe on Thursday 9th of October 2014 09:27:55 AM
Old 10-09-2014
I see no exit for sqlplus... and I also am no more much in oracle but at the time I used start commmand, so if I adapt your code to the way I would have done, it would give:
In /tmp/query.sql:
Code:
WHENEVER SQLERROR EXIT
SPOOL /report/path/report.txt

SET ECHO OFF
SET TERMOUT OFF
SET PAGESIZE 50000
SET LINESIZE 32767
SET TRIMSPOOL ON
/*
SPOOL $OUT       # That I am not sure  since you are no more in a shell script but in a .sql
So  see above  but I let you try and you tell us... I have no more access to oracle...      */

The SQL code you had here.....

SPOOL OFF


Code:
#! /usr/bin/sh

OUT=/report/path/report.txt

#oracle variables
ORACLE_HOME=/path/oracle/client
export ORACLE_HOME
SQLPLUS=$ORACLE_HOME/bin/sqlplus
export SQLPLUS
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
TNS_ADMIN=/path/tnsnames
export TNS_ADMIN
SCRIPT_NAME=”$1” 
# I am trying to execute one .sql file first to see if the script is working

$SQLPLUS -s "user/pass@database" << END_SQL      # oracle will be looking for a .sql  so:
start  /tmp/query         
exit;
END_SQL


Last edited by vbe; 10-09-2014 at 10:59 AM.. Reason: Corrected spool
This User Gave Thanks to vbe For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sql plus report under unix environment

Hi i am creating a report with file format csv using sql plus commands under unix environment. I am sending this report using mailx command to excel spread sheet. when i opened the report my columns are merged. I need to manually pull each column to see whole column results. Is there any way in... (0 Replies)
Discussion started by: raosurya
0 Replies

2. Shell Programming and Scripting

Script needed to FTP a file from sql report to unix server

Hi All, I have a Sqlplus report which will create a file. I need a FTP Script that will be executed inside the Sqlplus Report to FTP the report output file to unix server. Thanks, Previn (0 Replies)
Discussion started by: vprevin
0 Replies

3. Shell Programming and Scripting

Using SQL in Unix

Please tell me how i can use SQL in my unix scripts. Please give examples. I just want to start writing some scripts for my use. Looking for ur cooperation. thanks (2 Replies)
Discussion started by: Mohit623
2 Replies

4. Shell Programming and Scripting

sql through unix.

when we are spooling query o/p to certain txt file,in that file how we can get headers in the query.(through unix shell scripting). for exmple q1="slect * from XXXXXX;"; sqlplus XXX/XXXX@XXXXX spool XXXX.txt $q1 spool off in the text file i want the headers of the query..... ... (1 Reply)
Discussion started by: bhagya.puccha
1 Replies

5. UNIX for Dummies Questions & Answers

SQL in Unix

Hi, I would like to access SQL plus from my unix, and learn to run some SQL scripts in Unix. How do i begin. Is there any known website that offers a quick tutorial or tips? Thanks, unxhopeful (4 Replies)
Discussion started by: unxhopeful
4 Replies

6. Shell Programming and Scripting

unix variables from sql / pl/sql

How do I dynamically assign the below output to unix shell variables so I can build a menu in a shell script? Example: var1 = 1 var2= SYSTEM var3 = 2 var4= UNDOTBS1 and so on, then in the shell script I can use the variables to build a menu. set serveroutput on declare... (2 Replies)
Discussion started by: djehres
2 Replies

7. UNIX for Dummies Questions & Answers

Execute PL/SQL function from Unix script (.sql file)

Hi guys, I am new on here, I have a function in oracle that returns a specific value: create or replace PACKAGE BODY "CTC_ASDGET_SCHED" AS FUNCTION FN_ASDSCHEDULE_GET RETURN VARCHAR2 AS BEGIN DECLARE ASDSchedule varchar2(6); ASDComplete... (1 Reply)
Discussion started by: reptile
1 Replies

8. Shell Programming and Scripting

How to use sql data file in unix csv file as input to an sql query from shell

Hi , I used the below script to get the sql data into csv file using unix scripting. I m getting the output into an output file but the output file is not displayed in a separe columns . #!/bin/ksh export FILE_PATH=/maav/home/xyz/abc/ rm $FILE_PATH/sample.csv sqlplus -s... (2 Replies)
Discussion started by: Nareshp
2 Replies

9. UNIX for Dummies Questions & Answers

SQL PLUS report formatting

Hi I am fetcthing the data from the oracle database using SQLPLUS. Here is my script #!/bin/ksh echo `sqlplus -s <<EOF set feedback off set linesize 5000 set pages 0 set space 0 set echo off set trimspool on set colsep '|' SELECT col1 , col2... (4 Replies)
Discussion started by: max_hammer
4 Replies

10. Shell Programming and Scripting

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX?

Please share the doc asap as very urgently required. (1 Reply)
Discussion started by: 24ajay
1 Replies
SQL::Translator::Producer::SQLServer(3pm)		User Contributed Perl Documentation		 SQL::Translator::Producer::SQLServer(3pm)

NAME
SQL::Translator::Producer::SQLServer - MS SQLServer producer for SQL::Translator SYNOPSIS
use SQL::Translator; my $t = SQL::Translator->new( parser => '...', producer => 'SQLServer' ); $t->translate; DESCRIPTION
This is currently a thin wrapper around the nextgen SQL::Translator::Generator::DDL::SQLServer DDL maker. Extra Attributes field.list List of values for an enum field. TODO
* !! Write some tests !! * Reserved words list needs updating to SQLServer. * Triggers, Procedures and Views DO NOT WORK # Text of view is already a 'create view' statement so no need to # be fancy foreach ( $schema->get_views ) { my $name = $_->name(); $output .= " "; $output .= "-- -- View: $name -- " unless $no_comments; my $text = $_->sql(); $text =~ s/ //g; $output .= "$text GO "; } # Text of procedure already has the 'create procedure' stuff # so there is no need to do anything fancy. However, we should # think about doing fancy stuff with granting permissions and # so on. foreach ( $schema->get_procedures ) { my $name = $_->name(); $output .= " "; $output .= "-- -- Procedure: $name -- " unless $no_comments; my $text = $_->sql(); $text =~ s/ //g; $output .= "$text GO "; } SEE ALSO
SQL::Translator AUTHORS
See the included AUTHORS file: http://search.cpan.org/dist/SQL-Translator/AUTHORS <http://search.cpan.org/dist/SQL-Translator/AUTHORS> COPYRIGHT
Copyright (c) 2012 the SQL::Translator "AUTHORS" as listed above. LICENSE
This code is free software and may be distributed under the same terms as Perl itself. perl v5.14.2 2012-05-10 SQL::Translator::Producer::SQLServer(3pm)
All times are GMT -4. The time now is 07:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy