Home > OS >  The below PLSQL Condition seems Ok but getting PLS-00103 Exception
The below PLSQL Condition seems Ok but getting PLS-00103 Exception

Time:09-27

if (insflag = 'P' and (dd_flag = 'DC' || dd_flag != 'CC' || dd_flag != 'BC' || dd_flag != 'AC')) then
{
        select * from tabOne;
}
elsif (del_flag = 'DC' || del_flag = 'CC' || del_flag = 'BC' || del_flag = 'AC') then
{
        select * from tabTwo;
}

Exception: PLS-00103: Encountered the symbol "=" when expecting one of the following: . ( ) , * @ % & - / at mod remainder rem <an exponent (**)> and or as || The symbol ")" was substituted for "=" to continue.

Kindly help

CodePudding user response:

It seems OK? I don't think so. This is Oracle's PL/SQL, so:

  • OR should be used, not double pipe || (that's concatenation operator in Oracle)
  • no curly brackets
  • you're missing END IF

When fixed:

   IF (    insflag = 'P'
       AND (   dd_flag = 'DC'
            OR dd_flag != 'CC'
            OR dd_flag != 'BC'
            OR dd_flag != 'AC'))
   THEN
      SELECT * FROM tabOne;
   ELSIF (   del_flag = 'DC'
          OR del_flag = 'CC'
          OR del_flag = 'BC'
          OR del_flag = 'AC')
   THEN
      SELECT * FROM tabTwo;
   END IF;

However, that's still wrong and won't work because - in PL/SQL - you have to select into something. select * suggests that you'll be selecting all rows from these tables so you most probably can't use a scalar variable. One option is to use bulk operation and select everything into an array.

Basically, it depends on what you want to do.

  • Related