Java Stored proc giving an error

meallhour

I am trying to create a stored proc the following way:

DROP procedure IF EXISTS plus1inout
/;
CREATE procedure plus1inout (IN arg int, OUT res int)
BEGIN ATOMIC
    set res = arg + 1;
END
/;

I am getting the following error:

Msg 156, Level 15, State 1.
Incorrect syntax near the keyword 'IF'.
Msg 156, Level 15, State 1.
Incorrect syntax near the keyword 'IN'. (Line 3)
Pரதீப்

Your syntax isn't valid in sql server.

For checking the existence use object_id function

IF OBJECT_ID('plus1inout', 'P') IS NOT NULL
    DROP PROCEDURE plus1inout

For input parameter you don't have to mention IN keyword. For OUTPUT parameter use the keyword OUT at the end. Also parameters starts with @ in Sql Server

CREATE PROCEDURE Plus1inout (@arg INT,
                             @res INT output)
AS
  BEGIN
      SET @res = @arg + 1;
  END 

In SQL SERVER 2016 they introduced the syntax you have used for checking the existence of a procedure

DROP procedure IF EXISTS plus1inout

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

mysterious runtime error in stored proc

From Dev

If statement in JAVA giving error

From Dev

Error Testing PL/SQL Insert Stored Proc

From Dev

Importing LinkedList in Java giving an error

From Dev

Java - Client giving error on connect

From Dev

Importing LinkedList in Java giving an error

From Dev

Call MySQL Stored Procedure in a C application giving an error

From Dev

Stored Procedure in Oracle giving error PLS-00428

From Dev

Call MySQL Stored Procedure in a C application giving an error

From Dev

Stored procedure in Oracle using Select Command and Variables giving error

From Dev

Stored procedure terminating without giving error when executing from program

From Dev

MariaDB stored proc - Getting an error 'Missing SELECT' on INSERT statement

From Dev

Packets out of order error when calling MySQL stored proc

From Dev

MariaDB stored proc - Getting an error 'Missing SELECT' on INSERT statement

From Dev

System Error &h80040e14 when running Stored Procedure from VBA to Stored Proc on server

From Dev

Java 8 Method expression is giving compilation error

From Dev

Initialising Java String literal giving error

From Dev

java code is not compiling, neither giving any error

From Dev

java stream collect function giving error

From Dev

Recursive Java method giving stack overflow error

From Dev

Java web service not giving error message

From Dev

java console applicaiton giving error for port 1433

From Dev

Bing Speech API giving error with JAVA code

From Dev

select stored proc plsql

From Dev

STORED PROC - select then insert

From Dev

STORED PROC - select then insert

From Dev

Java code giving error,: Syntax error or token "1", < expected

From Dev

Java code giving error,: Syntax error or token "1", < expected

From Dev

Error in tSQLStoredProc in Delphi XE2 when importing stored proc from Oracle XE 11g?

Related Related

  1. 1

    mysterious runtime error in stored proc

  2. 2

    If statement in JAVA giving error

  3. 3

    Error Testing PL/SQL Insert Stored Proc

  4. 4

    Importing LinkedList in Java giving an error

  5. 5

    Java - Client giving error on connect

  6. 6

    Importing LinkedList in Java giving an error

  7. 7

    Call MySQL Stored Procedure in a C application giving an error

  8. 8

    Stored Procedure in Oracle giving error PLS-00428

  9. 9

    Call MySQL Stored Procedure in a C application giving an error

  10. 10

    Stored procedure in Oracle using Select Command and Variables giving error

  11. 11

    Stored procedure terminating without giving error when executing from program

  12. 12

    MariaDB stored proc - Getting an error 'Missing SELECT' on INSERT statement

  13. 13

    Packets out of order error when calling MySQL stored proc

  14. 14

    MariaDB stored proc - Getting an error 'Missing SELECT' on INSERT statement

  15. 15

    System Error &h80040e14 when running Stored Procedure from VBA to Stored Proc on server

  16. 16

    Java 8 Method expression is giving compilation error

  17. 17

    Initialising Java String literal giving error

  18. 18

    java code is not compiling, neither giving any error

  19. 19

    java stream collect function giving error

  20. 20

    Recursive Java method giving stack overflow error

  21. 21

    Java web service not giving error message

  22. 22

    java console applicaiton giving error for port 1433

  23. 23

    Bing Speech API giving error with JAVA code

  24. 24

    select stored proc plsql

  25. 25

    STORED PROC - select then insert

  26. 26

    STORED PROC - select then insert

  27. 27

    Java code giving error,: Syntax error or token "1", < expected

  28. 28

    Java code giving error,: Syntax error or token "1", < expected

  29. 29

    Error in tSQLStoredProc in Delphi XE2 when importing stored proc from Oracle XE 11g?

HotTag

Archive