1

I'm creating stored procedure in mysql. I declare some variables, but occur error. I don't know problem.

Error is

"Incorrect synstax near 'Declare'".

CREATE PROCEDURE SP_APPDOCLISTSIGNBOXREAD_GET(
P_SESSIONID         VARCHAR(256),
P_EMPID             VARCHAR(20),
P_FORMSEQ           VARCHAR(5)
)
BEGIN
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

    DECLARE V_DRAFTDEPT  VARCHAR(20); -- ***This line is error.***
    DECLARE V_ADMINCOUNT INT;

    SET @V_STRSQL = '';         -- Dynamic query variable
    SET @V_STRWHERE = '';       -- Dynamic query variable   
    SET @V_STRPARAM = '';       -- Dynamic query variable

    SET V_DRAFTDEPT = '';
    SET V_ADMINCOUNT = 0;

    SELECT DEPTCODE INTO V_DRAFTDEPT
      FROM TBEMPLOYEE
     WHERE EMPID = P_EMPID;
END
2
  • Move SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; after the DECLAREs. Commented Jul 1, 2016 at 0:41
  • Thank you for answer!!^^ Good day! Commented Jul 1, 2016 at 1:22

1 Answer 1

1

The order of statements with a MySQL program is pretty specific.

The DECLARE statements have to come first.

And there's an order for the DECLARE statements too. For example, any DECLARE ... HANDLER statements must come after variable declarations.


If it wasn't clear... MySQL is returning an error for the DECLARE statement because it's not valid following a SET statement.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your answer!! Good day ^^

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.