LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-12-2008, 07:37 AM   #1
anandv_1234
LQ Newbie
 
Registered: Dec 2007
Posts: 8

Rep: Reputation: 0
Question How to run sql programs in Unix Env?


Hi Folks,

I have a sql program in my home directory and i am able to run it in sqlplus enviornment, but i want to run this program in Unix Enviornment,means i want to write a shell script which has to call my sql program....

Can any one help me out on this?

Thanks in advance....

With Regards,
V.Anand,
Bangalore.
 
Old 02-12-2008, 09:35 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Here documents are a way to do this, or if you have the sql statements in a 'sql-file' you can call sql with that file.

Here document example:
Code:
#!/bin/bash

sqlplus -s user/password <<EOF
SET PAGES 0
SET ECHO OFF
SET FEEDBACK OFF
SET TERMOUT OFF
SET LINES 132

SPOOL /tmp/dis_spec_const.sql
SELECT x from y where a equals b

SPOOL off

EOF
All between The first EOF and the closing EOF will be given to sqlplus.

Using a file that sqlplus 'executes' is also possible:
Code:
#!/bin/bash

sqlplus user/passwd @dir/sql-commands.do
All the commands in dir/sql-commands.do are executed.

Hope this helps.
 
Old 02-12-2008, 11:24 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by druuna View Post
Code:
#!/bin/bash

sqlplus user/passwd @dir/sql-commands.do
All the commands in dir/sql-commands.do are executed.

Hope this helps.
Or have the credentials in a file, too, so
you don't see them in ps' output ... that's
what we do at work.



Cheers,
Tink
 
Old 02-12-2008, 11:28 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

@Tinkster: Very good point! (and I'm a bit ashamed I overlooked that, I should know better.....).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run pl/sql from Unix shell scripts? plz us_chauhan Linux - Server 2 05-15-2007 10:35 AM
Switch to another user, get his env and run a command 'under his name' ganninu Linux - General 2 05-25-2004 02:26 PM
Unix/Xenix programs wonīt run in Linux trupillo Linux - Software 3 05-21-2004 12:13 PM
init on boot programs that need env vars The_Spider Linux - General 3 04-29-2004 07:30 AM
How to set SQL to UNIX socket Skunk_Face Linux - General 1 01-19-2004 06:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration