Appian Community and Appian Academy are being upgraded. As a part of the upgrade, Appian Community is currently in read-only mode, and user registration is disabled until August 3. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

Regarding the MariaDB transactions

In My Practice Application,

I have an accounts table that contains the details of the account holder like the name, balance, etc.

Here, I am writing a stored procedure to transfer an amount from one account to another account

          in the Transfer Amount stored procedure, 2 steps need to be included in a transaction, 

                            1)  subtracting amount from the sender account.

                            2) Adding amount to the receiver account 

  Discussion posts and replies are publicly visible

  • +1
    Certified Associate Developer

    Hi mohan, can you please try the below code. Here I have used customer and accounts table for example. If there is an error signal, customer table will be printed, else account table will be printed.

    DELIMITER $$
    CREATE DEFINER=dbadmin@% PROCEDURE transactionCode()
    BEGIN
        DECLARE _rollback BOOL DEFAULT 0;
        DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET _rollback = 1;
            
        START TRANSACTION;
            SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "This above executed SQL statements will be rollbacked";
        IF _rollback 
        THEN
            ROLLBACK;
            SELECT * from Customer;
        ELSE
            COMMIT;
            SELECT * from accounts;
        END IF;
    END$$
    DELIMITER ;