b1234 b1234 - 8 days ago 5
SQL Question

User Does not Exist Oracle SQL developer

Forgive me if this is a simple fix, I am quite new to SQL, just started learning it on Tuesday. So I am experimenting with functions and made a simple one to test it out such as

CREATE FUNCTION CHINOOKHW.AddPara(@a1 int, @b2 int)
RETURN INT
BEGIN AS
DECLARE @C3 INT = SUM(A1, B2)
RETURN @C3
END
GO
CHINOOKHW.AddPara(1, 2);


but I get the error

Error report -
ORA-01435: user does not exist
01435. 00000 - "user does not exist"
*Cause:
*Action:


I have already defined my user as

CREATE USER chinookhw
IDENTIFIED BY p4ssw0rd;


And while I know this is normally bad practice, I even gave my user all access like

GRANT ALL PRIVILEGES to chinookhw IDENTIFIED BY p4ssw0rd;


I am not sure if this is relevant but I a connected to the chinook database from
https://chinookdatabase.codeplex.com/

and I made another connection from the system database with the lines

GRANT DBA TO chinook;
GRANT DBA TO chinookhw;
commit;


Can anyone tell me what I am doing wrong? I've been at this for hours with no fix. Thank you in advance

Answer

Try the following - note how it's not specifying the user that the function is to be created under. Note also how the syntax is PL/SQL and not T-SQL or whatever it is you wrote yours in:

CREATE FUNCTION AddPara(a1 integer, b2 integer)
RETURN INTeger
BEGIN AS
  return A1 + B2;
END;
/
Comments