Operand should contain 1 column(s) Error occurred in mysql insert statement:

When i Execute this stored procedure the error occured (Operand should contain 1 column(s) Error occured)

Sample mysql procedure:


CREATE PROCEDURE spUrlinfo($mode int,
$OriginalUrl longtext,
$RewriteUrl longtext,
$ForumId varchar(100),
INOUT $Code varchar(100))
BEGIN
  IF $mode = 0 THEN
    SELECT
      @Code := NEWCODE('');
    SET $Code = @Code;
    INSERT INTO Urlinfo (Code, OriginalUrl, RewriteUrl, ForumId)
      select ($Code, $OriginalUrl, $RewriteUrl, $ForumId);
    SET $Code = CONVERT(@@identity, char);
  ELSE
    IF $mode = 1 THEN
      SELECT
        *
      FROM Urlinfo;
    ELSE
      IF $mode = 2 THEN
        SELECT
          *
        FROM Urlinfo;
      END IF;
    END IF;
  END IF;
END
Answer
Procedure insert query syntax error.
INSERT INTO Urlinfo (Code, OriginalUrl, RewriteUrl, ForumId)
values($Code, $OriginalUrl, $RewriteUrl, $ForumId);?
Insert query select statement is replaced to values.

Post a Comment

0 Comments