Home » SQL & PL/SQL » SQL & PL/SQL » Error In Function (Oracle 10g)
Error In Function [message #601955] Wed, 27 November 2013 13:44 Go to next message
Rasol_57
Messages: 18
Registered: November 2012
Location: India
Junior Member
I wrote this Function

(i used Oracle ODP.NET)

CREATE FUNCTION "MYSCHEMA"."MY_FUNC"(PARAM1 VARCHAR(4000))
RETURNS INT
SPECIFIC SQL110520140321900 BEGIN ATOMIC
DECLARE VAR1 INT;
DECLARE VAR2 INT;
SET VAR1 = NEXTVAL FOR SEQ_TBL_CONTRACTTOEOFFICIAL;

RETURN VAR1;
END

but , The following error appear :

ORA-00921: unexpected end of SQL command

why ?
Re: Error In Function [message #601956 is a reply to message #601955] Wed, 27 November 2013 14:16 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
you must use only valid syntax to avoid compilation errors
SQL> ed
Wrote file afiedt.buf

  1  CREATE FUNCTION "MY_FUNC"(PARAM1 VARCHAR(4000))
  2  RETURNS INT
  3  SPECIFIC SQL110520140321900 BEGIN ATOMIC
  4  DECLARE VAR1 INT;
  5  DECLARE VAR2 INT;
  6  SET VAR1 = NEXTVAL FOR SEQ_TBL_CONTRACTTOEOFFICIAL;
  7  RETURN VAR1;
  8* END;
  9  /

Warning: Function created with compilation errors.

SQL> show error
Errors for FUNCTION "MY_FUNC":

LINE/COL ERROR
-------- -----------------------------------------------------------------
1/34     PLS-00103: Encountered the symbol "(" when expecting one of the
         following:
         := . ) , @ % default character
         The symbol ":=" was substituted for "(" to continue.

2/1      PLS-00103: Encountered the symbol "RETURNS" when expecting one of
         the following:
         return


Re: Error In Function [message #601958 is a reply to message #601955] Wed, 27 November 2013 14:34 Go to previous message
John Watson
Messages: 8922
Registered: January 2010
Location: Global Village
Senior Member
I think there is an error on every line of your code.
Are you actually trying to write PL/SQL, or is it some other language?
Previous Topic: how to create local user in Database 12c
Next Topic: constraints error
Goto Forum:
  


Current Time: Thu Mar 28 09:51:56 CDT 2024