Displaying the data from the select query in a particular format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Displaying the data from the select query in a particular format
# 8  
Old 12-07-2007
hey
if you want to put your desired format in .txt file ,

then

change the following line in the script
database_retrieve_script.sh

HTML Code:
# replacing LOGFILE="databaseRetrieve.log to"
LOGFILE="databaseRetrieve.txt"
and as earlier retriveData.sql has
HTML Code:
select '$'||ColumnName1||'$'||ColumnName2 from <retrieveTable>;
then run database_retrieve_script.sh.
and then check databaseRetrieve.txt ....

hopes i understood your query ????????Smilie
# 9  
Old 12-10-2007
Manas,

I want to store the data in this format in a .txt file:-

$Jason$30
$Bill$23
$Roshan$25.

When i retrieve the data from the database i will getting the data as junk and it wont be displayed in any format.
To get the data in the above format, what i need to do ?
I need to parse the data and set it with the delimeter $.
How to do it..Pls. do help me in this..
# 10  
Old 12-10-2007
No replies for this..Pls. do shed some light into this..It is really urgent.
# 11  
Old 12-10-2007
Did you try the suggested solution?


Code:
$ sqlplus -s '/ as sysdba'<<!
> set pages 0 feed off echo off
> select '$'||name||'$'||age from retrieveTable;
> !
$Jason$30
$Bill$23
$Roshan$25

# 12  
Old 12-11-2007
Thanks..When i try to use sqlplus i am getting an error saying "sqlplus : not found". sqlplus is a default command in shell script ? or we need to install it?
pls. do provide an answer for this..
# 13  
Old 12-11-2007
Quote:
Originally Posted by sachin.tendulka
Thanks..When i try to use sqlplus i am getting an error saying "sqlplus : not found". sqlplus is a default command in shell script ? or we need to install it?
pls. do provide an answer for this..
No,
sqlplus is an oracle utility, not a standard shell command.
Given your question, I believe you should read the Oracle documentation first ...
# 14  
Old 12-11-2007
rado, Can u shed some light in to this..whether i need to install sql * plus in Unix to make use of the sqlplus utility? What are the setup i need to follow? or any classpath settings? Pls. do provide some help...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help in executing select query from perl script

Hi, I have a perl snippet that call a select query with a bind variable,when i compile the script I'm unable to get the query output. The same query when i fire in sqlplus fetches few rows. The query takes bit time to fetch results in sqlplus. my $getaccts = $lda->prepare("select distinct ... (1 Reply)
Discussion started by: rkrish
1 Replies

2. Shell Programming and Scripting

Displaying output in the tabular format

Hi I want to display the following input data into the tabular format as shown in the output. Input.txt: Following jobs are in pending state for more than 10 minutes: JOB_ID JOB_SUBMIT_ID MAHAR 784308 PUNJA 109367 Following jobs are running for longer time: JOB_ID... (1 Reply)
Discussion started by: dats
1 Replies

3. UNIX for Advanced & Expert Users

mysql select query optimization..

hi.. i need to optimize my select query .. my situation is like this .. i have 15 lac recors in my table.. the following query takes nine seconds to give the required output.. SELECT max(ah.AUC_AMT), SUBSTRING_INDEX(GROUP_CONCAT(SUBSTRING_INDEX(ah.AUC_CUS_NAME,'@',1) order by AUC_AMT... (1 Reply)
Discussion started by: senkerth
1 Replies

4. Shell Programming and Scripting

mysql select query optimization..

hi.. i need to optimize my select query .. my situation is like this .. i have 15 lac recors in my table.. the following query takes nine seconds to give the required output.. SELECT max(ah.AUC_AMT), SUBSTRING_INDEX(GROUP_CONCAT(SUBSTRING_INDEX(ah.AUC_CUS_NAME,'@',1) order by AUC_AMT... (0 Replies)
Discussion started by: senkerth
0 Replies

5. Shell Programming and Scripting

Select query implement in a shell

I have been asked to create a shell script that accepts a number of SQL select queries as input, runs them in sequence, spools the output to an EXCEL workbook, where, each worksheet is an output of a Select statement run above. The workbook should be in a .XLS format. If a particular select... (2 Replies)
Discussion started by: ShellNovice1
2 Replies

6. Shell Programming and Scripting

Displaying the output in the tabular Format

Hi, I have a file which contains the data in the below format and need to develop a script which will give the output in the tabular format. Could you please advice me. Folder: Workflow: version . Workflow run status: Workflow run error code: Schedule time: Workflow run type: ... (2 Replies)
Discussion started by: kandi.reddy
2 Replies

7. Shell Programming and Scripting

Redirect Postgresql Select Query to Variable

How to redirect postgresql select query to a variable using shell scripts? I tried to use psql -c "select ip from servers" db | egrep '+\.+\+\+' | sed 's/^ *\(.*\) *$/\1/' Output: 10.10.10.180 10.10.10.181 It display ip addresses from the databasem, but how could i redirect the... (3 Replies)
Discussion started by: uativan
3 Replies

8. Shell Programming and Scripting

how to convert the result of the select query to comma seperated data - urgent pls

how to convert the result of the select query to comma seperated data and put in a .csv file using korn shell. Pls help me as its very urgent. Thanks, Hema. (1 Reply)
Discussion started by: Hemamalini
1 Replies

9. Shell Programming and Scripting

Need Help (Select query)

Dear All, This may sound a simple query but a non technical person like me is not able to do it, So please help me out. I m using Unix... isql I jst wanted to do something like following select * from xyz where ID= xxxxxxxx (8 digit ID) Here if i put single 8 digit ID then the... (5 Replies)
Discussion started by: topgear1000cc
5 Replies

10. Shell Programming and Scripting

How to store the data retrived by a select query into variables?

Hi Friends, Can u please help mw with the following query . I need to run a database sql statement to select particular fields from a table.I need to store the retrieved filed values into variables so that i can print it in a specific format. But the particular select query retrieves more... (12 Replies)
Discussion started by: jisha
12 Replies
Login or Register to Ask a Question