Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I have a database set up in MySQL with the following tables.
- mysql> describe transaction;
- +-------------------+-------------+------+-----+---------+-------+
- | Field | Type | Null | Key | Default | Extra |
- +-------------------+-------------+------+-----+---------+-------+
- | transaction_id | int(11) | YES | | NULL | |
- | description | varchar(40) | YES | | NULL | |
- | amount | int(3) | YES | | NULL | |
- | timestamp | datetime | YES | | NULL | |
- | debit_account_id | int(3) | YES | | NULL | |
- | credit_account_id | int(3) | YES | | NULL | |
- +-------------------+-------------+------+-----+---------+-------+
- 6 rows in set (0.02 sec)
- mysql> describe account;
- +------------+-------------+------+-----+---------+-------+
- | Field | Type | Null | Key | Default | Extra |
- +------------+-------------+------+-----+---------+-------+
- | account_id | int(11) | YES | | NULL | |
- | last_name | varchar(20) | YES | | NULL | |
- | first_name | varchar(20) | YES | | NULL | |
- | balance | int(11) | YES | | NULL | |
- +------------+-------------+------+-----+---------+-------+
- 4 rows in set (0.00 sec)
- I was successful to create the tables on LibreOffice. I need to create a LibreOffice application to execute something like the following SQL command:
- mysql> START TRANSACTION; set @transaction_id=1 ; set @description="Therapy" ; set @amount=8 ; set @debit_account_id=0 ; set @credit_account_id=1 ; UPDATE account SET balance = balance - @amount WHERE account_id = @debit_account_id; UPDATE account SET balance = balance + @amount WHERE account_id = @credit_account_id ; INSERT INTO transaction VALUES(@transaction_id, @description, @amount, NOW(), @debit_account_id, @credit_account_id);
- The LibreOffice application should have a form that takes and assign the variables:
- @transaction_id
- @description
- @amount
- @debit_account_id
- @credit_account_id
- and then executes the former SQL command. How can it be done?
Advertisement
Add Comment
Please, Sign In to add comment