no found record print out "no record found"

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

no found record print out "no record found"

#1 Post by flaskvacuum » 15 Mar 2013 02:56

i am thinking if there is no ORA- error found in the log,
it will print out "NO ORA-ERROR found"

Code: Select all

   if (findstr "ORA-[0-9]" alert_OCEAN_test.log neq 0) (
      echo NO ORA-ERROR found>>%output%
   )


flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: no found record print out "no record found"

#2 Post by flaskvacuum » 15 Mar 2013 03:27

Code: Select all

findstr "ORA-[0-9]" alert_OCEAN_test.log
If %ERRORLEVEL% EQU 1 echo NO ERROR FOUND>>%output%


so far the above work.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: no found record print out "no record found"

#3 Post by foxidrive » 15 Mar 2013 03:28

This is a method that runs when the errorlevel is true.

The || runs statements when errorlevel is true and && runs statements when the errorlevel is false.

Code: Select all

findstr "ORA-[0-9]" "alert_OCEAN_test.log" >nul || echo NO ORA-ERROR found>>%output%



Your method above will not do anything if the errorlevel is above 1 although that is usually an error condition.

mfm4aa
Posts: 70
Joined: 13 Feb 2013 14:02
Location: Europe

Re: no found record print out "no record found"

#4 Post by mfm4aa » 15 Mar 2013 03:48

or use the ERRORLEVEL function:

Code: Select all

findstr "ORA-[0-9]" alert_OCEAN_test.log
If ERRORLEVEL 1 echo NO ERROR FOUND>>%output%


This catches all errorlevels above zero.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: no found record print out "no record found"

#5 Post by foxidrive » 15 Mar 2013 04:32

mfm4aa wrote:or use the ERRORLEVEL function:
This catches all errorlevels above zero.


Yes, it does.

The trouble in this case is that it would be an error condition and the log would state that the text isn't found (NO ERROR FOUND).

I was thinking it earlier but didn't comment... this is probably better to catch that kind of error.

Code: Select all

findstr "ORA-[0-9]" "alert_OCEAN_test.log" >nul
If %ERRORLEVEL% EQU 1 echo NO ERROR FOUND>>%output%
If ERRORLEVEL 2 echo An error occured in Findstr & Pause

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: no found record print out "no record found"

#6 Post by flaskvacuum » 15 Mar 2013 04:39

foxidrive wrote:This is a method that runs when the errorlevel is true.

The || runs statements when errorlevel is true and && runs statements when the errorlevel is false.

Code: Select all

findstr "ORA-[0-9]" "alert_OCEAN_test.log" >nul || echo NO ORA-ERROR found>>%output%



Your method above will not do anything if the errorlevel is above 1 although that is usually an error condition.


very true . indeed better logic then mine. Thanks.

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: no found record print out "no record found"

#7 Post by flaskvacuum » 15 Mar 2013 04:39

mfm4aa wrote:or use the ERRORLEVEL function:

Code: Select all

findstr "ORA-[0-9]" alert_OCEAN_test.log
If ERRORLEVEL 1 echo NO ERROR FOUND>>%output%


This catches all errorlevels above zero.


this one very good too. Thanks! :wink:

Post Reply