mysql stored procedure syntax error

前端 未结 2 766
暖寄归人
暖寄归人 2021-01-28 20:46

Ok, this is only the second stored procedure I\'ve written. I think you\'ll get the idea, I\'m trying to close a credit line, and all invoices, charges, notes, etc with it. Bu

相关标签:
2条回答
  • 2021-01-28 21:20

    Hmm, im no expert at stored procedures, but isn't it.

    CREATE PROCEDURE `cc`.`close_account_proc`(cid INT)
        BEGIN
            // your stuff
        END$$
    
    0 讨论(0)
  • 2021-01-28 21:26
    DELIMITER $$
    
    CREATE PROCEDURE `cc`.`close_account_proc`(cid INT)
    BEGIN
        /* Check that it's what you wanted */
        SELECT  uid_usr
        INTO    @uid_usr
        FROM    credit_acc
        WHERE   type_acc = 'init'
                AND credit_used_acc = cid;
    
        UPDATE credit_acc SET status_acc = 'closed', void_date_acc = NOW() WHERE credit_used_acc = cid;
        UPDATE payment_acc SET status_acc = 'voided', void_date_acc = NOW()  WHERE creditid_acc = cid;
        UPDATE sbal_sbl SET status_sbl = 'voided', void_date_sbl = NOW()  WHERE credit_used_acc = cid;
    
        /* Check that it's what you wanted */
    
        INSERT
        INTO    notes_not (uid_usr, initials_not, status_not, date_not, text_not)
        VALUES  (@uid_usr, 'SYS', 'complete', NOW(), CONCAT('Closed credit line ', cid));
    
        UPDATE invoices_inv SET status_inv = 'voided', void_date_inv = NOW()  WHERE credit_used_acc = cid;
    END
    $$
    
    DELIMITER ;
    
    0 讨论(0)
提交回复
热议问题