How to take data from table?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to take data from table?
# 8  
Old 07-24-2012
Hi , i have a table called table1..
inside the table1 ,i have data like this ..
Code:
year    period  startdate        enddate
2013     1       26/03/2012    29/04/2012
2013     2       30/04/2012    27/05/2012
2013     3       28/05/2012    28/06/2012
2013     4        25/06/2012   29/07/2012
.....
......
......

so , i need the output quarter wise (ie period (1 to 3) as 1 is first quarter , (4 to 6) as 2 is second quarter)

while running we are giving the inputs for ex ..
Code:
./venky$ filename year period 
./venky$ filename 2013   1      (1 is first quarter) -> outputs should be first quarter details


Last edited by Franklin52; 07-24-2012 at 08:51 AM.. Reason: Please use code tags for data and code samples, thank you
# 9  
Old 07-25-2012
Problem understood, table contents understood. I am sorry to be that slow - where and how is yout table stored and accessed?
# 10  
Old 07-25-2012
How to export table record

<LI class="step " itxtHarvested="0" itxtNodeId="18">1 Log into the Unix machine with your Oracle username.


<LI class="step " itxtHarvested="0" itxtNodeId="17">2 Open a terminal window.


<LI class=googleAd itxtHarvested="0" itxtNodeId="16">3


<LI class="step " itxtHarvested="0" itxtNodeId="15">Type the command "sqlplus" to log into the Oracle database. You will be presented with the "SQL>" command prompt where you will type the following commands.


<LI class="step " itxtHarvested="0" itxtNodeId="14">4 Type the command "SET SPACE 0" to set the space between columns in the text file.


<LI class="step " itxtHarvested="0" itxtNodeId="13">5 Type the command "SET LINESIZE 75" to set the line size for the text file.


<LI class="step " itxtHarvested="0" itxtNodeId="12">6 Type the command "SET PAGESIZE 0" to suppress all headings, page breaks, titles, the initial blank line and other formatting information in the text file.


<LI class="step " itxtHarvested="0" itxtNodeId="11">7 Type the command "SET HEADING OFF" to suppress the printing of page headings in the text file.


<LI class="step " itxtHarvested="0" itxtNodeId="10">8 Type the command "SET MARKUP HTML OFF SPOOL OFF" stop the printing of HTML markup information.


<LI class="step " itxtHarvested="0" itxtNodeId="9">9 Type the command "SET COLSEP " "" to use a space (" ") to separate the columns in the text file.


<LI class="step " itxtHarvested="0" itxtNodeId="8">10 Type the command "SPOOL output.txt" to send the output of the following statements to a text file named "output.txt."


<LI class="step " itxtHarvested="0" itxtNodeId="7">11 Type the statement "SELECT * from table;" to select all of the data from the table. Replace the the word "table" with the actual name of the table.


<LI class="step " itxtHarvested="0" itxtNodeId="6">12 Type the command "SPOOL off" to stop the writing of output to the text file.


<LI class="step " itxtHarvested="0" itxtNodeId="5">13 Type the command "QUIT" to exit the Oracle database. You will be presented with the normal Unix command prompt where you will type the next command.


<LI class="step " itxtHarvested="0" itxtNodeId="4">14 Type the command "cat output.txt" to view the contents of the text file.




thanks,
Vinodh
# 11  
Old 07-26-2012
So your file actually is a spool output (text) from an ORACLE db. Why don't you use itkamaraj's proposal to create an output file tailored to your needs?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tabulate data in a table.

I have about a million tables stored as .txt files in a directory. The content of the files look like this: ages-eligible-for-study: genders-eligible-for-study: accepts-healthy-volunteers: CONTINUE 18-months-to-36-months both yes CONTINUE DONEOther examples, CONTINUE... (8 Replies)
Discussion started by: shoaibjameel123
8 Replies

2. Shell Programming and Scripting

Getting data in table form

Hi, I have a csv file from which i am fetching few columns as below: IFILE=/home/home1/Report1.csv OFILE=/home/home1/`date +"%m%d%y%H%M%S"`.dat if #Checks if file exists and readable then awk -F "," '(NR>4) {print $1,$6,$2,$3,$4,$5,$6}' ${IFILE} >> ${OFILE} fi cat $OFILE | mail... (7 Replies)
Discussion started by: Vivekit82
7 Replies

3. Shell Programming and Scripting

Arrange data in table

Hello All, I have following data into my file named record. Name City phone number email Jhon Newyork 123456987 jhon@gmail.com Maria Texas 569865612 Maria_Sweet@rediffmail.com Chan Durben NA Chan123@gmail.com The output should be in straight columns.. There should not be any... (1 Reply)
Discussion started by: Nakul_sh
1 Replies

4. Shell Programming and Scripting

Arrange data in table

Hello All, I have following data into my file named record. Name City phone number email Jhon Newyork 123456987 jhon@gmail.com Maria Texas 569865612 Maria_Sweet@rediffmail.com Chan Durben NA Chan123@gmail.com |---------------------------------------------------------------| |Name ... (2 Replies)
Discussion started by: Nakul_sh
2 Replies

5. Shell Programming and Scripting

Take Data From a table and send it through mail

Hi can anyone help me in writing a code for taking data from a table and need to send that data through mail using mail -x command.. (3 Replies)
Discussion started by: ginrkf
3 Replies

6. UNIX for Dummies Questions & Answers

Append data 1 table to other

Hi. I have 2 create 2 temporary tables.the data will be same with same cols..but after creating 2 tables..i have to merge data in file and send..however the query is after merging data no duplicates shud be present..and only 1 record for a entity must be present.. for eg: table1 has foll cols... (3 Replies)
Discussion started by: musu
3 Replies

7. UNIX for Advanced & Expert Users

Data from table to column

Hi All, in bash I have a text file which is something like 7.96634E-07 1.0000 0.00000E+00 0.0000 0.00000E+00 0.0000 1.59327E-06 0.7071 2.23058E-05 0.1890 6.61207E-05 0.1098 1.13919E-04 0.0865 1.47377E-04 0.0747 .... .... 0.00000E+00 0.0000 0.00000E+00 0.0000 ... (6 Replies)
Discussion started by: f_o_555
6 Replies

8. Shell Programming and Scripting

Data table

Hi there, I get a list of data set by means a script with many echo command that looks like this: CASE 1 A= 4 B= 4 CASE 2 A= 3 B= 5 Is... (3 Replies)
Discussion started by: Giordano Bruno
3 Replies

9. Shell Programming and Scripting

Showing several data in one table

hi again :$ i am creating a script to be able to monitor a machine's performance. the code in the file is: ================q============== sar 2 3 |awk '{print $3}' vmstat 2 3 |awk '{print $19 " " $21}' iostat -cx 2 3 |awk '{print $8 " " $10 " " $13}' ================uq============= the... (4 Replies)
Discussion started by: mohamedh_14
4 Replies
Login or Register to Ask a Question