LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 06-06-2008, 01:12 AM   #1
Swapna173
LQ Newbie
 
Registered: Dec 2007
Posts: 25

Rep: Reputation: 15
Using Linux Varibles to call SQL - Procedure


Hi Guys,

I need to validate certain records in sql tables inserted through sql-loader.

for this, i wrote a procedure which takes the oracle user name as parameter.

And i am running this procedure through scripting. but i need to hardcode this username(wherever i user this procedure). so instead of that i hav a file in scripting which initialized all variables.

so how can i use linux variables to call a procedure with that parameter.

Swapna
 
Old 06-06-2008, 03:39 AM   #2
Uxinn
Member
 
Registered: May 2008
Location: Iceland
Distribution: Ubuntu Hardy
Posts: 47

Rep: Reputation: 16
What are you using to test the table ? sqlplus ?
What type of script are you using to call your procedure ? bash or ?


If it's sqlplus and bash
then from within a bash script you could do

sqlplus USERNAME/PASSWORD@sid <<EOF
select * from dual;
EOF


So If you need to work with variables you can do that directly.
 
Old 06-09-2008, 01:14 AM   #3
Swapna173
LQ Newbie
 
Registered: Dec 2007
Posts: 25

Original Poster
Rep: Reputation: 15
Thanks i will try this out but how can i capture whether procedure executed successfully or not.
 
Old 06-10-2008, 05:00 AM   #4
Uxinn
Member
 
Registered: May 2008
Location: Iceland
Distribution: Ubuntu Hardy
Posts: 47

Rep: Reputation: 16
It's probably best to include
"WHENEVER SQLERROR EXIT 1"
in your sql that you are executing
Code:
--run.sql
WHENEVER SQLERROR EXIT 1
exec name_of_my_procedure();

Code:
sqlplus USERNAME/PASSWORD@sid<<EOF
WHENEVER SQLERROR EXIT 1
select * from dual;
EOF
SQLPLUS1=$?
sqlplus USERNAME/PASSWORD@sid<<EOF
WHENEVER SQLERROR EXIT 1
select * from duallllllll;
EOF
SQLPLUS2=$?

echo $SQLPLUS1
echo $SQLPLUS2
Here $SQLPLUS1 returns 0 but $SQLPLUS2 returns 1


Hope this helps,

Uxinn

Last edited by Uxinn; 06-10-2008 at 05:03 AM.
 
Old 07-29-2008, 02:29 AM   #5
Swapna173
LQ Newbie
 
Registered: Dec 2007
Posts: 25

Original Poster
Rep: Reputation: 15
Thanks

Thanks a lot. I will definately try this out.
 
  


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
PHP Varibles krilen Programming 0 12-13-2004 06:12 AM
Procedure call number is out of range China Jack Linux - Networking 1 06-11-2004 11:54 AM
how do I adjust environment varibles? purpleburple Linux - General 4 10-16-2002 03:31 PM
enviromental varibles rlpt Linux - General 1 03-14-2002 09:06 AM

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

All times are GMT -5. The time now is 10:24 PM.

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