Home > Software engineering >  oracle PLS-00103 Error after executing a simple query
oracle PLS-00103 Error after executing a simple query

Time:12-15

this is the code that I ran in the Oracle SQL Developer and the error has come next: It is a very simple query so what's wrong whit it?

DECLARE zero varchar(20);
DECLARE emptys;
begin
zero := '0';
emptys := null;
IF(emptys = zero)   then 
DBMS_OUTPUT.put_line('yes');
ELSE
dbms_output.Put_line('no'); 
end if;
end;
    

Error starting at line : 1 in command - DECLARE zero varchar(20); DECLARE emptys; begin zero := '0'; emptys := null;

IF(emptys = zero)   then 
DBMS_OUTPUT.put_line('yes');
ELSE
dbms_output.Put_line('no'); 
end if;

end;

Error report - ORA-06550: line 2, column 5: PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following:

begin function pragma procedure subtype type current cursor delete exists prior The symbol "begin was inserted before "DECLARE" to continue. ORA-06550: line 13, column 74: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

( begin case declare end exception exit for goto if loop mod null pragma raise return select update while with << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge json_exists json_value json_query json_object json_array 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:

CodePudding user response:

DECLARE indicates the beginning of the variable declaration section. You'd only have one such section. You don't repeat that keyword for every variable you declare.

You haven't provided a data type for the variable emptys. I'll assume you want that to be varchar2(20)

DECLARE 
  zero varchar(20);
  emptys varchar2(20);
begin
  zero := '0';
  emptys := null;
  IF(emptys = zero)   then 
    DBMS_OUTPUT.put_line('yes');
  ELSE
    dbms_output.Put_line('no'); 
  end if;
end;
    
  • Related