SQL QUERY to Table Output

Thread Tools Search this Thread
Operating Systems Solaris SQL QUERY to Table Output
# 1  
Old 03-17-2015
SQL QUERY to Table Output

I am trying to run sql query from solaris in csh script and send the output to email. Below is my sql query
select p.spid,se.program seprogram, se.machine, se.username, sq.sql_text,sq.retrows from v$process p
inner join v$session se on p.addr = se.paddr
 inner join
( select se1.sid,s1.sql_text,CASE WHEN s1.rows_processed > 0 THEN round((s1.rows_processed/s1.executions),0) END retrows  from
              (select * from v$session where sql_address is not null) se1
      inner join v$sql s1 on se1.sql_address = s1.address and se1.sql_hash_value = s1.hash_value
  select se2.sid,s2.sql_text,CASE WHEN s2.rows_processed > 0 THEN round((s2.rows_processed/s2.executions),0) END retrows from
              (select * from v$session where prev_sql_addr is not null) se2
      inner join v$sql s2 on se2.prev_sql_addr = s2.address and se2.prev_hash_value = s2.hash_value ) sq
            on sq.sid = se.sid
            where p.spid = $var;

Anyone can help to make the above sql query output in nicer format prefer in table format with border?
# 2  
Old 03-17-2015
sqlplus has various format options which can generate almost anything format wise.

Check out this document :
Formatting SQL*Plus Reports

Have you tried some options it provides ?

# 3  
Old 03-17-2015
You should decide if you want ASCII text output or HTML output for pretty printing.
For the latter, read the manual reg. SET MARKUP HTML ON/OFF.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sql query output count

Hi Team, below sql rerturn 20 records, the result set i am going to assign to one variable and it showing count is 1. and i don't use count() in sql query... based on count, i need to fail the script. No_of_step=`echo ${g_count} | wc -l` function gf_count() { g_count=`sqlplus -s... (8 Replies)
Discussion started by: bmk123
8 Replies

2. Shell Programming and Scripting

How to create a file from output of vertica table query in UTF-8 format?

Hello, In my shell script, I extract table data from HP Vertica DB into a csv file using vsql -c command. But the problem is the file getting created is in binary format and hence some of the data becomes unreadable which has chinese characters as part of data. file -i filename.csv - gives... (2 Replies)
Discussion started by: Dharmatheja
2 Replies

3. Shell Programming and Scripting

How to Assign the Output of an SQL Query to a Variable?

Hi iam new to shell scripting how to declare variables as redshift query and I have to compare two counts by using if condition . ex:count=select count(*) from prd; select count(*) from prd; select count(*) from tag; can any one help me . Please use CODE tags when displaying... (1 Reply)
Discussion started by: sam526
1 Replies

4. Shell Programming and Scripting

I want query output to send on mail using table tag and output should be in table

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (21 Replies)
Discussion started by: ankit.mca.aaidu
21 Replies

5. Shell Programming and Scripting

Shell scripting unable to send the sql query data in table in body of email

I have written a shell script that calls below sql file. It is not sending the query data in table in the body of email. spool table_update.html; SELECT * FROM PROCESS_LOG_STATS where process = 'ActivateSubscription'; spool off; exit; Please use code tags next time for your code and data.... (9 Replies)
Discussion started by: Sharanakumar
9 Replies

6. Shell Programming and Scripting

How to remove characters for sql query output?

Hi, my sql query return below value for " $SQL_OPN_AMT " CUSTCODE OH OHOPNAMT_GL OHREFNUM -------------------------------- -- ----------- ------------------------------ OHENTDATE FCC --------- --- 1.1072256 IN 74.85 000072061 0 01-MAY-13 MVR 1.1072256 IN 751.72 0000744751 01-JUN-13 MVR... (3 Replies)
Discussion started by: ranabhavish
3 Replies

7. Programming

sql query to match condition from other table (time sensitive)

I know little SQL and could really use a hand here. I need to get the fields last_name, first_name and email from the table users and only if the entery with the same pkey in the table addresses, in the city column is Seattle. So if the city in the addresses table is Seattle, go to the table... (2 Replies)
Discussion started by: computethis
2 Replies

8. UNIX for Advanced & Expert Users

Output the SQL Query result to a File

Hello Guys, This message is somewhat relates with last thread. But I need to re-write thing. I start over a little. I am stuck now and need your help. Here is my script- #! /bin/ksh export ORACLE_HOME=/opt/oracle/app/oracle/product/9.2 /opt/oracle/app/oracle/product/9.2/bin/sqlplus -s... (5 Replies)
Discussion started by: thepurple
5 Replies

9. Shell Programming and Scripting

redirecting sql query output to a file

Hi, I am executing sql files in my unix shell script. Now i want to find whether its a success or a failure record and redirect the success or failure to the respective files. meaning. success records to success.log file failure record to failure.log file. As of now i am doing like... (1 Reply)
Discussion started by: sailaja_80
1 Replies

10. Shell Programming and Scripting

How to store the sql query's output in a variable

Hi, My requirement is : We are calling an sql statement from a UNIX session, and fetching data into some variables from a table .. now we are unable to access these variables from outside the SQL part. Please let me know how can I achieve this. Can you please share a code snippet which... (4 Replies)
Discussion started by: venkatesh_sasi
4 Replies
Login or Register to Ask a Question

Featured Tech Videos