Sponsored Content
Special Forums UNIX and Linux Applications linux sqlplus select results writes into file twice Post 302513049 by azuahaha on Tuesday 12th of April 2011 08:52:57 AM
Old 04-12-2011
Yes it seems so. I think I found the problem, bolded part is the problem which I did not include at the first post because I put here an example of my code, not itself...

Code:
cd /tmp

if [ ! -e pid.pid ];then
touch pid.pid
sqlplus -S user/password << EOF >/dev/null
SET HEAD OFF FEEDBACK OFF VERIFY OFF TERMOUT OFF ECHO OFF TRIMSPOOL ON SERVEROUTPUT OFF showmode off pagesize 0 heading off
SPOOL /tmp/selectResults.sql
#select columnA, columnB, columnC from server1.table1 where columnB = '1000';
select 'insert into server2.table2 (columnA, columnB, columnC) values(' || columnA || ',' || columnB || ', ' || columnC || ');' from server1.table2 where columnB = '1000';
SPOOL OFF
exit
EOF
rm -fr pid.pid
fi


Since I write this script in bash, I thought "#" would make that line commented but I forgot that I use SQL in those lines and I needed "--" to comment it...

I'm sorry for the trouble and wasting your time.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

select count(*) in sqlplus into variable unix shell

Need to select count(*) from table to check for zero result in unix script (2 Replies)
Discussion started by: struggle
2 Replies

2. UNIX for Advanced & Expert Users

Set shell variables from SQLPLUS query results

Hi All, I needed to get the result of two sqlplus queris into shell variables. After days of looking for the ultimate solution to this problem.. i found this... sqlplus -s USER/PASS@DB <<EOF | awk '{if(NR==1) printf("%s ", $1); if(NR==2) printf("%s ", $1);}' | read VAR1 VAR2 set head off... (2 Replies)
Discussion started by: pranavagarwal
2 Replies

3. Shell Programming and Scripting

In a csh script, can I set a variable to the result of an SQLPLUS select query?

Can someone tell me why I'm getting error when I try to run this? #!/bin/csh -f source ~/.cshrc # set SQLPLUS = ${ORACLE_HOME}/bin/sqlplus # set count=`$SQLPLUS -s ${DB_LOGIN} << END select count(1) from put_groups where group_name='PC' and description='EOD_EVENT' and serial_number=1;... (7 Replies)
Discussion started by: gregrobinsonhd
7 Replies

4. Shell Programming and Scripting

sqlplus: could it be dirrected do not printout anything, beside results?

I try to prepare a sufficient function to execute a sql-statement, getting back ONLY retrieved results! What I can't figured out how to make the sqlplus not printing the 'Connected to ...', 'Disconnected from...' and the executed statements after 'SQL> '. I am under impression that having... (5 Replies)
Discussion started by: alex_5161
5 Replies

5. Shell Programming and Scripting

redirecting oracle sqlplus select query into file

So, I would like to run differen select queries on multiple databases.. I made a script wich I thought to be called something like.. ./script.sh sql_file_name out.log or to enter select statement in a command line.. (aix) and I did created some shell script wich is not working.. it... (6 Replies)
Discussion started by: bongo
6 Replies

6. UNIX for Advanced & Expert Users

SQLPlus Select with Grep

I m trying to grep 'select * from' from a script, but the problem is with the * ... I think its taking * as some special character ... when I try to do grep '*' test (test is my test file) its displaying * But when I am trying to do grep 'select * from' test its not showing anything... (2 Replies)
Discussion started by: RDR
2 Replies

7. Shell Programming and Scripting

iterating over results from sqlplus

hi all, i am writing a ksh script, i am logging into an oracle db via sqlplus and running a select statement but i dont know how i can store the results from the sql so i can iterate over it and do more operations over it. I dont want to write a stored procedure with a cursor since i need to... (2 Replies)
Discussion started by: cesarNZ
2 Replies

8. Shell Programming and Scripting

Connecting sqlplus from UNIX with multiple select statement

hi, i have a requirement where i need to connect sqlplus from unix and i am able to do so by following command: cust_count=`sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID << EOF set pagesize 0 set feedback off set verify off ... (1 Reply)
Discussion started by: lovelysethii
1 Replies

9. Shell Programming and Scripting

How to pass Variable from shell script to select query for SqlPlus?

echo "set echo off"; echo "set feedback off"; echo "set linesize 4000"; echo " set pagesize 0"; echo " set sqlprompt ''"; echo " set trimspool on"; Select statement is mentioned below echo "select res.ti_book_no from disney_ticket_history res where res.ti_status =${STATUS} and... (7 Replies)
Discussion started by: aroragaurav.84
7 Replies

10. Shell Programming and Scripting

SQLPLUS command with more than 1 select statement

Hi all, I'm using below code processId=`sqlplus -s ${sysuser}/${syspwd} <<CHK_PROCESS whenever sqlerror exit sql.sqlcode; set head off feedback off echo off pages 0 SELECT PROCESS_ID FROM LSHADMIN.DATA_DOMAIN WHERE DOMAIN_NAME = '${tabname}' ... (8 Replies)
Discussion started by: Pratiksha Mehra
8 Replies
ACPIDUMP(1)                                                   General Commands Manual                                                  ACPIDUMP(1)

NAME
acpidump - dump a system's ACPI tables to an ASCII file acpixtract - convert ASCII acpidump output to raw binary table turbostat - gather performance statistics SYNOPSIS
acpidump [options] acpixtract [options] [filename] turbostat [options] [command [arg]...] DESCRIPTION
This manual page documents briefly the acpidump , acpixtract and turbostat commands. turbostat reads hardware registers and gather statistics on the processor clock frequency and C-state usage. Works properly on Nehalem and newer processors and on Linux kernel 2.6.30 and later versions. OPTIONS
acpidump options are as follow: -a, --addr 0x1234 look for tables at this phisical address -t, --table DSDT only dump table with DSDT signature -o, --output filename redirect output from stdout to filename -b, --binary dump data in binary form rather than in hex-dump format -l, --lenght 0x456 works only with --addr, dump phisical memory region without trying to understand it's contents -s, --skip 2 skip 2 tables of the given name and output only 3rd one -h, --help outputs an help message OPTIONS
acpixtract options are as follow: -a extract all tables, not just DSDT/SSDT -l list table summaries, do not extract -s<Signature> Extract all tables named <Signature> OPTIONS
turbostat options are as follow: -v makes turbostat more verbose -i <sec> polling interval, default is 5 When given a command turbostat runs it and outputs statistics gathered while the program was running. EXAMPLES
Dump the DSDT table to the file DSDT.aml in binary format (this can be disassembled later with iasl(1)): acpidump -b -t DSDT -o DSDT.aml Show the FACP table: acpidump -t FACP > FACP.dat acpixtract -a FACP.dat iasl -d FACP.dat Dump and extract all ACPI tables: acpidump -o DSDT.dat acpixtract -a Parse APIC tables: acpidump -o DSDT.dat acpixtract -sAPIC DSDT.dat SEE ALSO
iasl(1), AUTHOR
acpidump was written by Alexey Starikovskiy and Len Brown. This manual page was written by Mattia Dongili <malattia@debian.org>, for the Debian project (but may be used by others). October 19, 2005 ACPIDUMP(1)
All times are GMT -4. The time now is 05:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy