Oracle to shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Oracle to shell script
# 1  
Old 08-12-2013
Question Oracle to shell script

hi , i have some procedures that were written in oracle (sql/plsql).
I need to convert them into shell scripts. So is there any procedure to this. or any tools available to do this. I need some guidance on this as i am totally new . I dont know shell scripting at all. My main target get the logic from oracle procedure and implement in stored procedure Smilie
# 2  
Old 08-12-2013
Quote:
Originally Posted by harishbabuy
hi , i have some procedures that were written in oracle (sql/plsql).
I need to convert them into shell scripts. So is there any procedure to this. or any tools available to do this. I need some guidance on this as i am totally new . I dont know shell scripting at all. My main target get the logic from oracle procedure and implement in stored procedure Smilie
You dont convert .you implement pl/sql logic in the shell script

Code:
sqlplus -s $USER_ID@$SID/$PWD<<EOF>$CUR_DIR/sql_output.txt 
set feedback off
set heading off
select distinct account_no from adj  WHERE ADJ_TRANS_CODE=-2401  and request_status=1  and bill_ref_no=0
order by account_no;
EOF

in place of select statement you can write the PROCEDURE

This User Gave Thanks to rafa_fed2 For This Post:
# 3  
Old 08-12-2013
Question how to do it

how can i implement that logic in shell scripting. Any set of rules i can follow.
# 4  
Old 08-12-2013
Quote:
Originally Posted by harishbabuy
how can i implement that logic in shell scripting. Any set of rules i can follow.
Yes

Code:
sqlplus -s $USER_ID@$SID/$PWD<<EOF> ##here you connect to the DB EOF is marker.you can use anything

EOF

LIKE THIS

sqlplus -s $USER_ID@$SID/$PWD<<EOF>
your oracle stuff
EOF

Between the <<EOF till last you can execute sql,pl/sql statements
# 5  
Old 08-13-2013
Question cursor

hi i had some cursors defined in the stored procedure and some select statements. update statements n even insert. so how to implement all these?


Smilie
# 6  
Old 08-13-2013
Quote:
Originally Posted by harishbabuy
hi i had some cursors defined in the stored procedure and some select statements. update statements n even insert. so how to implement all these?


Smilie
Like this

Code:
#!/bin/sh
#######################################################################
# ORACLE ENVIRONMENT VARIABLE DECLARATION(check your ORACLE_HOME variable)
#######################################################################
ORACLE_HOME=/oracle/product/10g; export ORACLE_HOME 
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH

### Connecting to ORACLE DATABASE

echo "SQLPLUS CONNECTION"

sqlplus -s USERNAME/DB_PASSWD@ORACLE_SID<<EOF>
set feedback off
set heading off
select * from dual  ;
##write your procedures ,functions,etc here
EOF

###Check if connection to ORACLE DB was successfull of not
if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help on Oracle insert from shell script

Hi All I am trying to create a shell script to insert in to oracle table so far insert happens with out an issue, but i cant pass message variable to sqlplus script insert. i have highlighted the variable in red. Please help. thanks in advance. #!/bin/sh df -H | grep -vE... (3 Replies)
Discussion started by: LPK
3 Replies

2. Shell Programming and Scripting

How to pass Oracle sql script as argument to UNIX shell script?

Hi all, $ echo $SHELL /bin/bash Requirement - How to pass oracle sql script as argument to unix shell script? $ ./output.sh users.sql Below are the shell scripts and the oracle sql file in the same folder. Shell Script $ cat output.sh #!/bin/bash .... (7 Replies)
Discussion started by: a1_win
7 Replies

3. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

4. Shell Programming and Scripting

Shell script with Oracle PL/SQL

Hi Gurus, I am new to this unix world...I need your help to walk through. I want to learn shell scripting..... The shell script which can be able to use with oracle pl/sql... So please suggest me which shell is good. Which Unix/Linux version is good for this to Install to get practice the... (8 Replies)
Discussion started by: GaneshAnanth
8 Replies

5. Shell Programming and Scripting

Shell script to query Oracle table

Hi, unix gurnis I need help for following requirement for writing a shell scritp. log in to oracle database, query one table total records (select count(*) from table1), pass the return value to a file. Thanks in advance (2 Replies)
Discussion started by: ken002
2 Replies

6. Shell Programming and Scripting

Connect to oracle db using shell script

Hi, I want to connect to oracle db using unix shell script. And i want to retrieve data from db through shell script. Please help me as soon as possible. Thanks, J.P. Das (1 Reply)
Discussion started by: jyotidas
1 Replies

7. Shell Programming and Scripting

shell script - insert oracle

Hi Frnds, in shell script I have one problem while inserting into oracle table . my script #! /usr/bin/sh while read record do echo $record X=`sqlplus -s STN/errrmddb20@MAHFDR <<eof insert into STN.STN_ERROR_TABLE values($record); eof`... (12 Replies)
Discussion started by: Gopal_Engg
12 Replies

8. Shell Programming and Scripting

Shell Script for call a procedure in Oracle DB

Hi everyone! I'm new with Shell Scripting, and I have to do a shell script to call a procedure, which have 2 input parameters, the directory(from server) and the txt file (which have informations to update/insert in DB). I have to create a shell script to execute that procedure for each txt... (5 Replies)
Discussion started by: renatoal
5 Replies

9. Shell Programming and Scripting

oracle connection from shell script

Hi, For connecting to oracle my script is using the command sqlplus username/password@db_instance_name.For this to work i am setting ORACLE_HOME,TNS_ADMIN and ORACLE_SID in a seperate script.My question is,could we make a connection to oracle just by the command sqlplus... (4 Replies)
Discussion started by: DILEEP410
4 Replies

10. Shell Programming and Scripting

Shell Script for Data loading in Oracle

Hi All I am new to unix. I need a shell script to load a datafile in to oracle. I already have a control file, and data file. all I need is if i execute the shell it must load the data using the ctl file to table. Control file : PAY0001.ctl Datafile : mon_grs_det.dat log file :... (3 Replies)
Discussion started by: raghuraja_r
3 Replies
Login or Register to Ask a Question