Home > Back-end >  Oracle function errors Error(1,16): PLS-00103: Encountered the symbol "@"
Oracle function errors Error(1,16): PLS-00103: Encountered the symbol "@"

Time:07-30

Learning to create oracle user defined function and here is the code:

create or replace function testf(@a as int)
returns int is
begin
return
(@a 5)
end;

Why is this not working for me? Error: Error(1,16): PLS-00103: Encountered the symbol "@" when expecting one of the following: current delete exists prior

CodePudding user response:

If you use Oracle, then follow its syntax.

SQL> create or replace function testf (par_a in int)
  2    return int
  3  is
  4  begin
  5    return par_a   5;
  6  end;
  7  /

Function created.

SQL> select testf(100) result from dual;

    RESULT
----------
       105

SQL>

CodePudding user response:

create or replace function testf(a in int)
return int authid definer is
begin
  return (a 5)
end testf;
/
  1. Replace @a with a.
  2. Replace as with in
  3. Remove s from returns.
  4. To avoid a warning, add AUTHID DEFINER just before is.
  5. For readability, add testf after end.
  6. If part of a script, add a / on the line below end;
  • Related