The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Executing several bash scripts in succession fantasyland Shell Programming and Scripting 7 05-16-2009 07:54 PM
Specified Ksh but executing in bash akhilnagpal UNIX for Dummies Questions & Answers 7 02-04-2009 11:45 AM
executing mysql load statement from shell script DILEEP410 Shell Programming and Scripting 4 01-22-2009 03:18 AM
Executing a Oracle SQL statement in a UNIX script ganga.dharan Shell Programming and Scripting 1 12-08-2008 10:44 AM
installing Orcale 8i on unix Parameswaran.AR UNIX for Dummies Questions & Answers 1 03-15-2006 11:57 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-25-2009
satnamx satnamx is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 34
Bash executing Orcale Update statement

Hi All,

Using Solaris box
bash-3.00$ echo $BASH_VERSION
3.00.16(1)-release


I have a real bummer of a bug, basically Im running a bash script that executes a bash function "dbase_sql". The bash function accepts a parameter in the form of an Oracle update statement eg



dbase_sql "update dte_batch_details
set row_count='$row_count'
, checksum_value='$checksum_value'
, load_attempts=NVL(load_attempts,0)+1
, pre_stage_errors='$pre_stage_errors'
, message='$sql_err_msg'
where object_name='$source_tabin_name'"





The function itself is as below

dbase_sql()
{

echo "dbase_sql() 1.1 "
local sql="$1"
echo "sql="$sql
echo "showed ECHO!"
sqlplus -s $DBUSER/$DBPASS@$DBNAME<<EOF

set serveroutput on size 1000000
set verify off
set feedback off

VARIABLE vi_err NUMBER

declare

begin
${sql};
commit;
:vi_err:=0;

exception
when others
then
:vi_err:=1;
end;
/
EXIT:vi_err
EOF
}



The perplexing thing is that I cannot get the call to the function to work in my main shell script, so I created a simple script that calls the function and that does seem to work! For some reason, the bug is that the echo does not show the full statement in the function and hence it passes the malformed statement to the oracle call which then fails.

Error from the shell is as follows:

dbase_sql() 1.1
' , load_attempts=NVL(load_attempts,0)+1 , pre_stage_errors='Y' , message='/#SQL Loader Bad File[/export/home/ORACLE/product/10.2.0/TORPEDO/LOGS/SQLLDR_bad_TOS_TABIN218.bad]' where object_name='TOS_TABIN218'
showed ECHO!
Thursday, 25 June 2009 14:06:43 BST #Application Error - Abort: Call to dbase_func.dbase_sql()


The working version shows:

dbase_sql() 1.1
sql=update dte_batch_details set row_count='1' , checksum_value='1' , load_attempts=NVL(load_attempts,0)+1 , pre_stage_errors='Y' , message='None/#SQL Loader Bad File[]/#SQL Loader Bad File[]/#SQL Loader Bad File[]/#SQL Loader Bad File[]/#SQL Loader Bad File[]/#SQL Loader Bad File[]/#SQL Loader Bad File[]/#SQL Loader Bad File[]' where object_name='TOS_TABIN218'
showed ECHO!


Any ideas?!
Kind Regards
Satnam
  #2 (permalink)  
Old 07-06-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
Is there any difference between the echo syntax in your longer and the working shorter script? Basically you have problems with single and/or double quotation marks it seems. Maybe try playing around by escaping them with a backslash until you get the desired output.
Another way might be putting the statement to a plain file and then hand it over as a parameter to your script to have less hassle.
Also use CODE-tags when posting code, data or logs in future please.
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0