Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

VarChar2 Empty But Length Not Zero

user12983154Oct 15 2014 — edited Oct 16 2014

Hello,

In s stored proc I have a string declared as an empty string (2 single-quotes with no space in between):

    ErrMsgEx        varchar2(5000) := '';

later on in the code it checks if the error message is still empty, then process finished OK... as follows:

        if 1 > Length(LTrim(ErrMsgEx)) then

            ErrMsgEx := 'Process sSuccessful';

        else

            ErrMsgEx := ErrMsgEx || 'Process completed with errors';

        end if;

in the code line in boldface above I've also tried the following variations of the same logic:

        if ErrMsgEx = '' then

        if 0 = Length(ErrMsgEx) then

        if 0 = Length(Trim(ErrMsgEx)) then

        if 1 > Length(ErrMsgEx) then

        if 1 > Length(Trim(ErrMsgEx)) then

but running thru the debugger it shows that ErrMsgEx is empty, but when the IF is evaluated, it jumps to the ELSE branch

Is the code wrong? Why is it so cumbersome to test a string for emptyness?

Thanks in advance,

Richard

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 13 2014
Added on Oct 15 2014
14 comments
6,135 views