-
I have a text file looks like:
lang_tab id number
lang_tab name varchar2(10)
lang_tab suffix varchar2(10)
does anyone know/have a script to create output like:
an array with "," delimiter. e.g. id,name,sufix
thanks in advance
-
it looks like the file is space delimited, you can use:
cat file_name | awk '{print $1,","$2,","$3}'
-
#!/bin/sh
$ORACLE_HOME/bin/sqlplus -S usrename/password@servicename << EOF
set heading off
set pagesize 1000
set arraysize 100
spool filename
select id||","||name||","||suffix
from table_name;
spool off
EOF
exit
-----------------------
Sam
Thanx
Sam
Life is a journey, not a destination!
-
sorry, I did not make it clear. I want only display the 2nd field of each row and concated into a line with "," as delimiter.
the text file looks like 3xn
lang_tab id number
lang_tab name varchar2(10)
lang_tab suffix varchar2(10)
: : :
lang_tab user varchar2(16)
the output I want to be an array
id,name,suffix
thanks
-
Is your text file is fixed field format or variable filed format.
Sam
Thanx
Sam
Life is a journey, not a destination!
-
post a sample data and how you want it to become.
You might be able to do it in 'vi' itself.
svk
-
I spool
select TABLE_NAME,column_name,DATA_TYPE from user_tab_columns;
to a text file:
This is the sample data which spooled from sqlplus
cust_tab custid number
cust_tab custname varchar2(20)
cust_tab ...
: : :
cust_tab user varchar2(16)
lang_tab langid number
lang_tab name varchar2(10)
lang_tab suffix varchar2(10)
: : :
lang_tab user varchar2(16)
now, I need to create a string which contains all column name for each table.
output should be:
custid,custname,descption,..user
langid,langname,suffic,..user
-
Confusion !!
The SQL query that you have mentioned should create one line records (with proper linesize). The you can use the awk option you that has been posted earlier.
Why are you saying that you are getting one column per line ?
svk
-
I guess I still not make it clear enough. sorry.
Say I have 2 table cust_tab and lang_tab
cust_tab contains 5 columns: custid, custname, custaddr, custphone, updateuser.
lang_tab contain 4 columns: langid, langname, langdesc, updateuser.
I want create a list column name for each table. (one line per table, use "," to seperate columns)
so the output will be
custid, custname, custaddr, custphone, updateuser
langid, langname, langdesc, updateuser
----
I assume I should spool them into a text file
the text file will be:
cust_tab custid number
cust_tab custname varchar2(20)
cust_tab custaddr varchar2(40)
cust_tab custphone varchar2(16)
cust_tab updateuser varchar2(16)
lang_tab langid number
lang_tab langnam varchar2(30)
lang_tab langdesc varchar2(30)
lang_tab updateuser varchar2(16)
then AWK to lines. how?
thanks
-
If you need the SQL query to be in the text file format, go ahead and use the shell script what I had posted in there with your query parameters in place.
I still don't get what you are looking for???
Explain the purpose/need step by step.
Sam
Thanx
Sam
Life is a journey, not a destination!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|