I never did this before... what I want to do is execute a SQL query from a unix script and redirect sql query's output to a flat file (comma separated one) without the header info (no column names). I would also want not to print the query's output to the screen.
Problem is that sql.out contains all other things that I do not want.. it contains column names after every certain no of records, contains info such as "connected to oracle database" and all that...
Is there any other way to do this?
I used SQLLDR to load data from flat file to the database table. Can I use SQLLDR for reverse action - from table to file? Syntax?
Almost there.... thanks
only one problem... each row in output file is distributed in multiple lines...
How can I get each row in only one line... 2nd row in 2nd line...so on?
I hope I am not asking too much...
I used LTRIM to remove trailing whitespaces... but output file has fixed column width.
I want to embed "," between columns to make it a csv file and do not want any trailing white spaces either. Any idea how to do it?
How to set column size in such a way that it will be equal to the number of characters present in the column (excluding trailing white spaces)? So instead of fixed column width, it will be a variable one.
For eg:
---------- Post updated at 04:19 PM ---------- Previous update was at 01:27 PM ----------
One last question:
I am able to create a csv file now, but when I open it in windows (double click)... leading zeros in certain columns are missing... may be because of text to number conversion..
How can I avoid this? Is it something that I can specify in sqlplus while fetching the records from the table and save it in the csv file?
As I already mentioned it is behavior of your spreadsheet application.
If it is just numeric with leading zero, then it will strip leading zeros. Or you might have to put a symbol or character as prefix to preserve the zeros.
But I don't think that is what you want :rolleyes: