I'm creating a function that ensures all outdated employee ids are updated to be have a total of 4 numbers. For example, if a employee's id was 11, it would be concatenated with two 0's: 0011. I keep getting an error:
Error(19,4): PLS-00103: Encountered the symbol ";" when
expecting one of the following: if
It is flagging at the first nested if:
create or replace function ID_RENEWAL(OLD_ID IN VARCHAR2)
return VARCHAR2
is UPDATED_ID VARCHAR2(4);
begin
if (length(OLD_ID) < 4) THEN
UPDATED_ID := '0'||OLD_ID;
if (length(OLD_ID) < 4) THEN
UPDATED_ID := '0'||OLD_ID;
if (length(OLD_ID) = 4) THEN
return (UPDATED_ID);
end if;
end if;
else
UPDATED_ID := SUBSTR(OLD_ID, 1, 4);
return (UPDATED_ID);
end;
Any ideas?