Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6895721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:56:42+00:00 2026-05-27T06:56:42+00:00

i hv a prob here which already took me days to solve it.. my

  • 0

i hv a prob here which already took me days to solve it..

my explanation will be quite lengthy but i try to keep it short.

in my Oracle SQLdeveloper, i have a package name UT_BETWNSTR which contain:

create or replace
PACKAGE "UT_BETWNSTR" 
IS
PROCEDURE ut_setup;
PROCEDURE ut_teardown;

PROCEDURE ut_betwnstr;
END UT_BETWNSTR;

and the package body is like this:

    create or replace
PACKAGE BODY      "UT_BETWNSTR" 
IS
   PROCEDURE ut_setup IS
   BEGIN
      NULL;
   END;

   PROCEDURE ut_teardown
   IS
   BEGIN
      NULL;
   END;

   PROCEDURE ut_BETWNSTR IS
      BEGIN
       utAssert.eq (
            'Typical valid usage',
             BETWNSTR(
             STRING_IN => 'abcdefg',
             START_IN => 3,
            END_IN => 5)
           ,
         'abc'
         );
         utAssert.isnull (
           'NULL start',
             BETWNSTR(
             STRING_IN => 'abcdefg',
             START_IN => NULL,
             END_IN => 5)
           );
           utAssert.isnull (
              'NULL end',
            BETWNSTR(
            STRING_IN => 'abcdefg',
            START_IN => 2,
             END_IN => NULL)
           );
           utAssert.isnull (
                  'End smaller than start',
                   BETWNSTR(
                   STRING_IN => 'abcdefg',
                   START_IN => 5,
                   END_IN => 2)
          );
          utAssert.eq (
                  'End larger than string length',
                   BETWNSTR(
                   STRING_IN => 'abcdefg',
                   START_IN => 3,
                   END_IN => 200)
           ,
         'cdefg'
         );

           END ut_betwnstr;

END UT_BETWNSTR;

and the function name BETWNSTR is like this:

create or replace
FUNCTION BETWNSTR (
   string_in   IN   VARCHAR2,
   start_in    IN   INTEGER,
   end_in      IN   INTEGER
)
   RETURN VARCHAR2
IS
   l_start PLS_INTEGER := start_in;
BEGIN
   IF l_start = 0
   THEN
      l_start := 1;
   END IF;

   RETURN (SUBSTR (string_in, l_start, end_in - l_start + 1));
END;

in my C drive, i put a file name BETWNSTR.sql which contain:

connect hr/hr
SET SERVEROUTPUT ON
EXEC UTPLSQL.TEST('BETWNSTR',Recompile_in=>FALSE);
exit

and this is my batch file (also in C drive), name try.bat which contain:

@sqlplus /nolog @C:\betwnstr.sql

echo %errorlevel%
if errorlevel 0 goto Success
echo You Got Error

:Success
echo Good Job!!

pause

ok here comes the error

when i run try.bat, it will return the big FAILURE result as i purposely put

PROCEDURE ut_BETWNSTR IS
  BEGIN
   utAssert.eq (
        'Typical valid usage',
         BETWNSTR(
         STRING_IN => 'abcdefg',
         START_IN => 3,
        END_IN => 5)
       ,
     'abc'
     );

instead of

PROCEDURE ut_BETWNSTR IS
  BEGIN
   utAssert.eq (
        'Typical valid usage',
         BETWNSTR(
         STRING_IN => 'abcdefg',
         START_IN => 3,
        END_IN => 5)
       ,
     'cde'
     );

i did that in purpose so that i hope the cmd will echo out:

You Got Error

because got error in my code..but the errorlevel is echoing 0 which mean it is a success..

i know, my code now is depending on errorlevel..when errorlevel is 0 it will echo out Good Job..

what i want right now is, when i run the batch file, when it encounter an error, i can echo out You Got Error message..

how can i echo out “You Got Error” message when the errorlevel is always showing 0..

in short, i want to echo out error message without depending on errorlevel..

i am hoping anybody hv the solution for my problem could pls answer my question..

Thanks In Advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:56:43+00:00Added an answer on May 27, 2026 at 6:56 am

    I am not sure if this will work, but perhaps it is worth a shot. ( I do not have a windows machine, so I cannot test, but it looks about right ) This will depend on sql’s ability to write to standard output. I don’t know Oracle, so I don’t know if you can get it to do this, but if you can, the little hack below should work, if you know the standard pattern of error/warning messages. If /nolog stops printing to standard output, take it out of the below snippet. Worth a shot. Good luck! 🙂

    setlocal enabledelayedexpansion
    
    some_text_signifying_error=whatever you can get sql to display to Standard Output
    set msg=''
    
    For 'eol=; tokens=1 delims=' %%e in ('@sqlplus /nolog @C:\betwnstr.sql ^| findstr /i /c:"!some_text_signifying_error!"') do (
        set msg=!msg! %%e
    )
    
    if NOT !msg!='' echo !msg!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am prob. being pretty dense here but I can't figure out exactly what
I expierencing something strange. Prob it's easy, but my css knowhow stops here. In
Here is my prob in Brief. I know how to upload a file to
this is prob pretty easy but if someone could explain the easiest way to
i've a prob here, so i need a help:) When i'm calculating expression like
I know this has prob been answered, but I've searched for almost an hour
This question is prob a duplicate (but I can't find it) so I apologize
I've got an example mht file here that will help demonstrate my issue; if
I can put value into array and here is my code and prob. Search.h
there. I've searched my question around here but failed to find anything relevant. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.