Home » Infrastructure » Unix » Logic Validation
Logic Validation [message #270114] Tue, 25 September 2007 15:12 Go to next message
reksab_16
Messages: 8
Registered: September 2007
Junior Member
Unix gurus,

I have a requirement in shell script where I have to connect to the DB and execute a script (Disabling Constraints) and subsequently do some loading process, if the disabling of the constraints is successful. Else, I have to write to the error file and abandon the process.

Error message is basically I want to take the first line in the Variable PM_Error.

The following is the Logic I wrote.

Is this valid? Any help on this is very much appreciated.

### SqlCall For Disabling the Constraints on anp_pmk_item_xref table
export PM_Error=`sqlplus -s $PM_UP <<END
      set heading off
      set verify off
      set feedback off
      set newp NONE
      @anp_pmk_item_xref_dis_cons.sql
/
END`

if [expr $PM_Error : 'ORA-'] 
then
   echo 'Unable to Disable the Constraints on anp_pmk_item_xref table>>${PM_ERRORFILE}
   export err_mess= substr($PM_Error,1,match($PM_Error,' '))
   echo $PM_Error>>${PM_ERRORFILE}
   exit
fi

Re: Logic Validation [message #270168 is a reply to message #270114] Wed, 26 September 2007 00:48 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Quote:
Can anybody please help me on this?

Maybe not those who are awake and hearing.
And maybe if you'd follow the rules you'd get more answers.

Please read and follow OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format. Use the "Preview Message" button.
Please always post your Oracle version (4 decimals).

Regards
Michel

[Updated on: Wed, 26 September 2007 08:40]

Report message to a moderator

Re: Logic Validation [message #270308 is a reply to message #270168] Wed, 26 September 2007 08:30 Go to previous messageGo to next message
Frank Naude
Messages: 4581
Registered: April 1998
Senior Member
Try something like this:

OUTPUT=`sqlplus -s scott/tiger <<END
      SELECT * FROM dual;
      EXIT 0;
END`

ERROR=`echo $OUTPUT | grep ORA-`

if [ "$ERROR" = "" ]; then
   echo 'No error - continue'
else
   echo 'Error - stop!'
fi
Re: Logic Validation [message #270394 is a reply to message #270168] Wed, 26 September 2007 14:25 Go to previous messageGo to next message
reksab_16
Messages: 8
Registered: September 2007
Junior Member
Frank,

Thanks for the needful. It was really helpful.

Can you please suggest me tutorial, which contains practical examples to begin with?

Thanks and regards,

Bhaskar Natarajan.
Re: Logic Validation [message #270395 is a reply to message #270394] Wed, 26 September 2007 14:32 Go to previous messageGo to next message
Frank Naude
Messages: 4581
Registered: April 1998
Senior Member
Do a "man" on the shell you are using. For example, if you use bash:

$ man bash
Re: Logic Validation [message #270400 is a reply to message #270114] Wed, 26 September 2007 15:04 Go to previous messageGo to next message
reksab_16
Messages: 8
Registered: September 2007
Junior Member
Frank,

It is giving the following message.

Manual entry for bash not found or not installed.

Thanks and Regards,

Bhaskar Natarajan
Re: Logic Validation [message #270404 is a reply to message #270400] Wed, 26 September 2007 15:25 Go to previous message
Frank Naude
Messages: 4581
Registered: April 1998
Senior Member
You should also be able to get it on the web. For example: http://www.gnu.org/software/bash/manual/bashref.html
Previous Topic: Find a String on a variable
Next Topic: Getting Server Info Through Proc
Goto Forum:
  


Current Time: Sat Nov 23 22:31:24 CST 2024