{Urgent very need help} script for conn oracle and get the content


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting {Urgent very need help} script for conn oracle and get the content
# 1  
Old 02-01-2007
Error {Urgent very need help} script for conn oracle and get the content

hi experts,

very need help about script how to login into oracle database and select a table and append the query into a file.

i have oracle database and have a table named omc_ip with fields like host_id(varchar2(20)),ip(varchar2(10)) and update_date(date).

i want to build a script that can connect to oracle database and query this table and put the output into a file.

nb:using oracle8i database and solaris 8 sparc

please help

Thank you so much for your attention


Best Regards,

bucci
# 2  
Old 02-01-2007
Code:
sqlplus username/password@connection_string <<EOF
spool /dir1/dir2/file
select * from omc_ip;
spool off
EOF

/dir1/dir2/file contain the result of the query
# 3  
Old 02-01-2007
Quote:
Originally Posted by anbu23
Code:
sqlplus username/password@connection_string <<EOF
spool /dir1/dir2/file
select * from omc_ip;
spool off
EOF

/dir1/dir2/file contain the result of the query

thank you so much anbu

Regards,

bucci
# 4  
Old 02-01-2007
Quote:
Originally Posted by bucci
thank you so much anbu

Regards,

bucci
hi anbu,

need some pretty advices for my output query.


my script database is :

#!/bin/sh

DAY=`/export/home/oracle/bin/lastdate | nawk '{print $1}'`

/export/home/orahome/bin/sqlplus -s user/pass<<eof
set heading off;
set linesize 100;

spool /export/home/oracle//log/$DAY.log
select ip,host_id from omc_ip ;
spool off;
EXIT;
eof


below is my output :

10.1.0.0 LDDS-IVR-2
10.1.0.0 LDDS-CS-A
10.1.0.0 USSDGsem1
10.1.0.0 USSDGsem2
10.1.0.0 USSDGsby1
10.1.0.0 USSDGsby2
10.1.0.0 USSDGmdn1
10.1.0.0 USSDGmdn2
10.1.0.0 USSDGtbs2
10.1.0.0 LDDS-IVR-1
10.1.0.0 USSDGtbs1
10.1.0.0 LDDS-MAP-B
10.1.0.0 LDDS-CS-B

10.1.0.0 LDDS-MAP-A
10.1.0.0 USSDGtbs3
10.1.0.0 USSDGmdn3
10.1.0.0 USSDGmdn4
10.1.0.0 USSDGsby3
10.1.0.0 USSDGsby4
10.1.0.0 USSDGtbs4

20 rows selected.

i want to throw away the blank line and the "20 rows selected."

any idea?


Thank you

Best Regards,

bucci
# 5  
Old 02-01-2007
If you use
Code:
set feedback off

you wont get "20 rows selected".

Use this to remove blank lines in the output file
Code:
sed "/^[[:space:]]*$/d" file

# 6  
Old 02-01-2007
Quote:
Originally Posted by anbu23
If you use
Code:
set feedback off

you wont get "20 rows selected".

Use this to remove blank lines in the output file
Code:
sed "/^[[:space:]]*$/d" file

hi anbu,

how to i bundle the sed command into my script ?

please advice

thank you

Regards,

bucci
# 7  
Old 02-01-2007
Code:
#!/bin/sh

DAY=`/export/home/oracle/bin/lastdate | nawk '{print $1}'`

/export/home/orahome/bin/sqlplus -s user/pass<<eof
set heading off;
set linesize 100;
set feedback off;

spool /export/home/oracle//log/$DAY.log
select ip,host_id from omc_ip ;
spool off;
EXIT;
eof
sed "/^[[:space:]]*$/d" /export/home/oracle/log/$DAY.log > tmp
mv tmp /export/home/oracle/log/$DAY.log 

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

2. Shell Programming and Scripting

File Content Loading to Oracle Error

I habe a UNIX Variablw with content as below: WHOLE_REC_TXT="$record" where $record contains contents of file Sample contents of file: topic_id|1624|AIDS-HIV|| topic_id|1625|Allergies|| topic_id|1626|Alzheimer s|| topic_id|1627|Knee Pain|| topic_id|1628|Autism||... (2 Replies)
Discussion started by: Arun Mishra
2 Replies

3. Red Hat

Help: Find established conn source

Hi Friends, On one of my server which having direct connection to internet without firewall ..am seeing a established connection with SSH .. am not getting how ..there no login but I can see this established connection . ## have hidden original IPs with below notations for security concerns .... (0 Replies)
Discussion started by: Shirishlnx
0 Replies

4. Shell Programming and Scripting

urgent help : want to check data in oracle from flate file

Hi All, I have a flat file like this on unix AIX server: MXBOFO CSWP 5340 3794499 MXBOBIS CSWP 5340 3581124 MXBOFO CSWP 5340 3794531 MXBOBIS CSWP 5340 3583720 MXBOFO CSWP 5340 3794514 MXBOBIS CSWP 5340 3580763 MXBOFO CSWP 5340 3795578 MXBOBIS CSWP 5340 3794995 MXBOFO CSWP 5340 3710835... (3 Replies)
Discussion started by: unknown123
3 Replies

5. UNIX for Dummies Questions & Answers

Doubt in Oracle connecting unix - Very urgent

I am using a oracle query from unix.. flag=`sqlplus -s <<EOF SELECT 'Y' FROM table_name WHERE cond1 = '${table_name}' AND DECODE('${var_a}','''NA''',own,'${var_b0}')= own exception when no_data_found then dbms_output.put_line(NVL(l_owner_flag,'X')); end; EOF` Its not validating the... (7 Replies)
Discussion started by: sivakumar.rj
7 Replies

6. UNIX for Advanced & Expert Users

conn

hai , i want to connect to global ftp through ip address. remote type is unix. sometimes it is connecting some times connection timed out is coming what is solution (1 Reply)
Discussion started by: rajan_ka1
1 Replies

7. Solaris

oracle on solaris, needed urgent help, require it for exams?

Hi all, I wanted to know how to install oracle on solaris (b83).. I also would like to know of a link that i can download oracle from? please reply fast.. I need it for my exams day after tomorrow... please reply (1 Reply)
Discussion started by: wrapster
1 Replies

8. Shell Programming and Scripting

how to store the first content of the folder in a variable?(Urgent)

Hi All, I need urgent help. Because just now i have to give this code to my client. I have a folder name is Testing. this Testing folder contains the following 3 files. 1.txt 2.txt 2.txt Now I want to store the first value of my folder in a variable say suppose $a. Means i want that... (3 Replies)
Discussion started by: sunitachoudhury
3 Replies

9. Shell Programming and Scripting

Urgent: selecting unique specific content of a file using shell script

Hi, I have a file whose content and format at places is as given below. print coloumn .... coloumn .... coloumn .... skip 1 line print coloumn ... skip 1 line I need to select the following : print coloumn .... coloumn .... coloumn... (2 Replies)
Discussion started by: jisha
2 Replies

10. UNIX for Advanced & Expert Users

URGENT: Password modification for oracle user

Hi to all, Need help! For user sysoper on oracle, I want to know who and on which date/time the password has been modified? The platform is unix itself. Thanks (2 Replies)
Discussion started by: ashvik
2 Replies
Login or Register to Ask a Question