简体   繁体   中英

MySql Code: 1241 operand should contain 1 column(s)

I found different topics here in stackoverflow related to Mysql Error: 1241. And as I read all the topics, they have some common issues related on their sub-queries. But my problem is different.

PROBLEM: - MySql Code: 1241 operand should contain 1 column(s)

FROM - One of my Stored Procedure with prepared statements

NOTE - My select statement has no sub-query as well as my update statement.

SCREEN SHOT - ACTUAL SS

STORED PROCEDURE CODE

CREATE PROCEDURE CancelRow_EM(IN tbl_name VARCHAR(25), IN rowindex FLOAT, OUT flagresult TINYINT, OUT msgresult VARCHAR(300))

 BEGIN
 START TRANSACTION;
IF tbl_name="emps_tbl" THEN
    SET @PrimaryCol="EMPS_ID";
    SET @RefCol="OBR NO.";

ELSEIF tbl_name="emmooe_tbl" THEN
    SET @PrimaryCol="EMMOOE_ID";
    SET @RefCol="PR NO.";

ELSEIF tbl_name="emco_tbl" THEN
    SET @PrimaryCol="EMCO_ID";
    SET @RefCol="PR NO.";

END IF;

SET @select1=CONCAT("SELECT `LINK_ID`,`",@RefCol,"` INTO @li,@Ref FROM `",tbl_name,"` WHERE ROUND(`EMPS_ID`,3)=",rowindex);
PREPARE stmtselect1 FROM @select1;
EXECUTE stmtselect1;
DEALLOCATE PREPARE stmtselect1; 

If @li IS NOT NULL THEN
    SET flagresult=0;
    SET msgresult="Cancellation of record was stopped. Reason: Earmark record was already utilize.";

ELSE
    SET @update1=CONCAT("UPDATE `",tbl_name,"` SET `CANCEL_STATUS`=1 WHERE ROUND(`",@PrimaryCol,"`,3)=",rowindex," AND `",@RefCol,"`='",@Ref,"'");
    PREPARE stmtupdate1 FROM @update1;
    EXECUTE stmtupdate1;

    SELECT row_count() INTO @RowsAffected1;
    DEALLOCATE PREPARE stmtupdate1;

    IF @RowsAffected1>0 THEN
        SET flagresult=1;
        SET msgresult=("No. of affected rows(s):",@RowsAffected1,", from modification process.");
        COMMIT;
    ELSE
        SET flagresult=0;
        SET msgresult=("There are no affected row(s) from modification process.");
        ROLLBACK;   
    END IF;
END IF;

END

You can't assign a tuple to a single variable.

This:

SET msgresult=("No. of affected rows(s):",@RowsAffected1,", from modification process.");

Should be:

SET msgresult=CONCAT("No. of affected rows(s):",@RowsAffected1,", from modification process.");

语法错误,从选择中删除()。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM