Cut an sql script output


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Cut an sql script output
# 1  
Old 06-22-2009
Data Cut an sql script output

Hi i want to cut the first field of this output obtained form sql script

more dxlocks_test.log.1

SID SERIAL# SPID
---------- ---------- ---------
25 18356 1029
78 39370 1025
136 14361 1027

================================
cut -f1 dxlocks_test.log.1 > compare
================================
more compare
SID SERIAL# SPID
---------- ---------- ---------
25 18356 1029
78 39370 1025
136 14361 1027
==================================
i thought the delimiter was tab, then i tried with space
cut -d' ' -f1 dxlocks_test.log.1 > compare
=================================
more compare

----------




====================================
This is the output.. i want to acutallly want to store each of the SID's in separate variable? So the approach i thought of was to first cut the coloum of sids, and then take 1 sid at a time and assign them in a variable.. can someone help with the cut command or any better way that i should look at
# 2  
Old 06-22-2009
It would be slight easier if you said in you SQL

Code:
heading off

to remove the SID SERIAL
and -------- lines

Then you could say

Code:
X=1
while read SID everything_else; do
  eval SIDS[$X]=$SID
  let X=$X+1
done < my_sids_list

Then you can access the SIDs as:

Code:
echo ${SIDS[1]}
...

# 3  
Old 06-22-2009
thanks .. actually wanted the heading.. dont matter will run another querry forthe output file..

will try an let u know how it works..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script appending output of sql query

I am writing the following script to create the file v_out.txt. sqlplus -s /nolog << EOF CONNECT scott/tiger@orcl; whenever sqlerror exit sql.sqlcode; set newpage 0; SET PAGESIZE 0; SET ECHO OFF; SET FEEDBACK OFF; SET HEADING OFF; SET VERIFY OFF; SET LINESIZE 100; set tab off; set... (7 Replies)
Discussion started by: itzkashi
7 Replies

2. Shell Programming and Scripting

SQL Query in Shell Script output formatting

Hi All, #!/bin/ksh call_sql () { sql=$1 sqlplus -s $sqlparam_sieb <<EOF SET ECHO OFF; SET NEWPAGE NONE; SET SQLBL OFF; SET VERIFY OFF; SET LINESIZE 2000; SET... (2 Replies)
Discussion started by: Kevin Tivoli
2 Replies

3. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

4. Shell Programming and Scripting

SQL Script's output to a CSV file

I need to call and execute an SQL script within a KSH script and get the output/extracted data into a CSV file. Is there any way to get the out put in a CSV file other than spooling ? I tried spooling. Problem is if there is any wrning/comment/Error they all will be spooled into the csv file. I... (4 Replies)
Discussion started by: Sriranga
4 Replies

5. Shell Programming and Scripting

Help in getting pl/sql output messages in script

Hi , I have a pl/sql procedure which takes its input from a shell script, and deletes rows from db table based on the input. I've dbms_output.put_line statments in procedure which i want to capture and display in the script and change the course of the execution of the script. for example,... (1 Reply)
Discussion started by: justchill
1 Replies

6. Shell Programming and Scripting

have a shell script done in pl/sql and want output in html

I have this shell script where I have both pl/sql and sql. But want to have a snigle output file where the result of each cursors are in HTML tables. I was able to do that on my old script but it was only sql scripts (no pl/sql). Can I do have such outputs now with my new script where I... (2 Replies)
Discussion started by: arobert
2 Replies

7. Shell Programming and Scripting

need help in reading a output of a sql query in unix script

i'm used a sql query in a unix script to get the information from table. but unable to extract the output which i need. Any help with logic will be greatly appreciated. my sql query provide output some thing like this - col1 col2 count ---- ---- ------ A B 10 c D 6 e... (8 Replies)
Discussion started by: pharos467
8 Replies

8. Shell Programming and Scripting

redirecting SQL output from within a shell script

Hi all I would like to open a SQL session from within a shell script and then redirect the output of the SQL command to a file. e.g. #!/bin/bash sqlplus "/ as sysdba" <<EOF @$HOME/recovery_space.sql EOF I want to redirect the output of the SQL command to a temp file, because... (2 Replies)
Discussion started by: soliberus
2 Replies

9. Shell Programming and Scripting

small script - get sql output & write into txt

Hi, how can I write a small script to run the following statement and output the result into check_result.txt select /*+RULE*/ tapname from typetbl where tapname like 'AA%' and rejectcode=9; Normally, I just type sql and get into SQL> (2 Replies)
Discussion started by: happyv
2 Replies

10. Shell Programming and Scripting

how to assign sql output data to shell script variable

Hi Guys ! I am new to unix and want to find out how we can make sql statement data to shell script variable? Any help/suggestion is greatly appreciated -Chandra (1 Reply)
Discussion started by: kattics
1 Replies
Login or Register to Ask a Question