Error with mysql procedures ERROR 1304 & ERROR 1305

前端 未结 1 537
走了就别回头了
走了就别回头了 2021-01-13 03:50

I am new to using procedures and cannot seem to get mine working. I am using MySQL v5.1.36 and inputing my code using MySQL Console on a WAMPP server. If I go to (re)create

1条回答
  •  有刺的猬
    2021-01-13 04:16

    I believe the problems are

    1. The first error occurs because you are attempting to re-create an existing procedure. If you were to drop the procedure first you would not get this error,
    2. The second error is because PROCEDUREs are invoked with CALL statements, while FUNCTIONs are invoked as function references, as in your code. You must define a FUNCTION, not a PROCEDURE. The (MySQL documentation) says:

    The CREATE FUNCTION statement is also used in MySQL to support UDFs (user-defined functions). See Section 21.2, “Adding New Functions to MySQL”. A UDF can be regarded as an external stored function. Stored functions share their namespace with UDFs. See Section 8.2.3, “Function Name Parsing and Resolution”, for the rules describing how the server interprets references to different kinds of functions.

    To invoke a stored procedure, use the CALL statement (see Section 12.2.1, “CALL Syntax”). To invoke a stored function, refer to it in an expression. The function returns a value during expression evaluation.

    0 讨论(0)
提交回复
热议问题