How to acheive ALT+Enter of xls in Unix ksh/sqlplus


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to acheive ALT+Enter of xls in Unix ksh/sqlplus
# 1  
Old 10-16-2006
How to acheive ALT+Enter of xls in Unix ksh/sqlplus

Hi,

I am using sqlplus (called inside my ksh) to create a file which is mailed to the users as an xls.
There is one DESCRIPTION column which is currently coming as wrapped, but, the users want a new line for each of the fields present in the desricription column.
Below is an example -

DESCRIPTION
-------------
Name:aaaaaa Base:123mn Loc:000454
Sequence:00000987 Shadow:Y

This is wrapped.
How the User wants this column is as follows -


DESCRIPTION
-------------
Name:aaaaaa
Base:123mn
Loc:000454
Sequence:00000987
Shadow:Y


This should be wrapped too but each field with its value should appear in a new line (like we give ALT+Enter in a xls to have a new line inside a cell).

Is this possible to do this in sqlplus?

I had tried giving the following Column command, but it is not working -
COLUMN DESCRIPTION FORMAT WORD_WRAP


Thanks,
Sree
# 2  
Old 10-16-2006
Sree,

Perhaps, you should be posting this to an sql forum.
# 3  
Old 10-16-2006
Agreed...Still ....if any leads could come through......
# 4  
Old 10-16-2006
I bet you can do natively in sqlplus, but ..... you can pipe the output of sqlplus into this 'nawk':
Code:
sqplus ....... | nawk 'RS=FS'

# 5  
Old 10-16-2006
Here's one sqlplus way to do it:
Code:
  1  SELECT text
  2        ,REPLACE (text
  3                 ,' '
  4                 ,CHR (10) ) text
  5  FROM   (SELECT 'desc1:value1 desc2:value2 desc3:value3' text
  6*         FROM   DUAL)
SQL> /

TEXT                                   TEXT
-------------------------------------- --------------------------------------
desc1:value1 desc2:value2 desc3:value3 desc1:value1
                                       desc2:value2
                                       desc3:value3

# 6  
Old 10-16-2006
But there are other columns as well that are selected in my sql -

My query goes like this -

select npp as NPP,error_message as ERROR,error_type as TYPE,data_selection as DA
TA_SELECTION,description as DESCRIPTION,item_cd as ITM_CD from export_test;


Could you please throw more light on nawk. Also, what does RS=FS signify?


Thanks.
# 7  
Old 10-16-2006
one more thing: sqlplus provides formatting capabilities for specific columns. If your values are going to be similar in size, the formatting command may do the trick.
Code:
  1  SELECT 'desc1:value1 desc2:value2 desc3:value3' wrapped_text
  2  FROM DUAL
SQL> column wrapped_text format a20 word_wrapped
SQL> /

WRAPPED_TEXT         
-------------------- 
desc1:value1         
desc2:value2         
desc3:value3

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Line break in sqlplus output through ksh script

Hi, I am new to shell script programming. I have written a ksh script to run the sql File placed in server directory and spool the output in destination directory. Below Command: $ORACLE_HOME/bin/sqlplus -s $ora_uid @$sqlfile_loc$testquery.sql > $opfiledirectory It is generating the output... (6 Replies)
Discussion started by: Sumit Arora
6 Replies

2. Shell Programming and Scripting

Merging Multiple XLS into Different tabs in xls/ xlsx

HI, I have multiple files per dept in folder for eg : In a folder File1_Dept100.xls File2_Dept100.xls File3_Dept100.xls File1_Dept200.xls File2_Dept200.xls File3_Dept200.xls Output should be : Dept100.xls which has File1, File2, File3 in different tabs Dept200.xls which has... (1 Reply)
Discussion started by: venkyzrocks
1 Replies

3. Shell Programming and Scripting

KSH - type ENTER to continue

Hello, Is ther any way to run a loop which promt an echo"waiting for user to hit ENTER" sleeps for an iterval and once user hit the ENTER key the loop exit and the script continue to the next stage? I need this ASAP !!! Thanks!! (9 Replies)
Discussion started by: LiorAmitai
9 Replies

4. Solaris

sqlplus output from ksh.

Hi All, I have the below simple script. It runs just fine by itself when I manually invoke it. But once I put it in the crontab with entry: * * * * * /users/myuser/test.ksh >> /users/myuser/log/test.txt" It does NOT print the returned value ($REMAIN) from the DB!? The result in the... (3 Replies)
Discussion started by: steve701
3 Replies

5. Shell Programming and Scripting

Enter an input and reference another line in ksh script

Hi I have a file like so: Code: Frank Peter Tony Robert Mike 1 2 3 4 5 5 4 2 3 1 4 3 1 5 2 My out should look like this: Peter Tony Mike and so on.... I have the first part done to ask the user to... (8 Replies)
Discussion started by: bombcan1
8 Replies

6. Shell Programming and Scripting

Mail to: cc: How can i acheive this with ksh

Hi All, I have to write a script to send mail, in that i have to dynamically add the recepient in TO and my cc is a common one. For all mails my cc recepients are same. Only problem with TO recepient. Please i am looking for your inputs. (1 Reply)
Discussion started by: Arunprasad
1 Replies

7. Shell Programming and Scripting

Simulate ENTER key in ksh scripting

Using SCO 5, Ksh here I am trying to automate some process that i am doing manually. During some point of time, I will have to press enter to clear away some messages. This is how I do manually. *one command* r r r r r I enter the command once, then press enter key 1 more... (6 Replies)
Discussion started by: khaos83_2000
6 Replies

8. Shell Programming and Scripting

KSH Sqlplus problem

Hi, trying this =============================== Temp=`sqlplus -s user/passwd <<EOF WHENEVER SQLERROR EXIT 1 set serverout on set feedback off set heading off select nam from tabel1 where x=y; EOF` echo Temp>>$logfile ================================= The select statement is... (2 Replies)
Discussion started by: amitkr
2 Replies

9. Shell Programming and Scripting

How to pass variable to SQLPLUS in a ksh script?

Hi, I am writing a ksh script which will use sqlplus to run a sql and pass 2 variables as the SQL request. In the ksh script, I have 2 variables which are $min_snap and $max_snap holding 2 different numbers. Inside the same script, I am using SQLPLUS to run an Oracle SQL script,... (6 Replies)
Discussion started by: rwunwla
6 Replies

10. Shell Programming and Scripting

Need help with ksh script that uses sqlplus, called from PHP

I have a ksh script that connects to sqlplus and dumps the query results into a file. The script works file when I run it from the command line, however, when I call it from PHP using system(), exec(), or shell_exec() commands, the script doesn't seem to run the query. It will create the text file... (7 Replies)
Discussion started by: j2owilson
7 Replies
Login or Register to Ask a Question