quiliro

form to execute SQL in LibreOffice

Apr 21st, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. I have a database set up in MySQL with the following tables.
  2.  
  3. mysql> describe transaction;
  4. +-------------------+-------------+------+-----+---------+-------+
  5. | Field | Type | Null | Key | Default | Extra |
  6. +-------------------+-------------+------+-----+---------+-------+
  7. | transaction_id | int(11) | YES | | NULL | |
  8. | description | varchar(40) | YES | | NULL | |
  9. | amount | int(3) | YES | | NULL | |
  10. | timestamp | datetime | YES | | NULL | |
  11. | debit_account_id | int(3) | YES | | NULL | |
  12. | credit_account_id | int(3) | YES | | NULL | |
  13. +-------------------+-------------+------+-----+---------+-------+
  14. 6 rows in set (0.02 sec)
  15.  
  16. mysql> describe account;
  17. +------------+-------------+------+-----+---------+-------+
  18. | Field | Type | Null | Key | Default | Extra |
  19. +------------+-------------+------+-----+---------+-------+
  20. | account_id | int(11) | YES | | NULL | |
  21. | last_name | varchar(20) | YES | | NULL | |
  22. | first_name | varchar(20) | YES | | NULL | |
  23. | balance | int(11) | YES | | NULL | |
  24. +------------+-------------+------+-----+---------+-------+
  25. 4 rows in set (0.00 sec)
  26.  
  27. I was successful to create the tables on LibreOffice. I need to create a LibreOffice application to execute something like the following SQL command:
  28.  
  29. 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);
  30.  
  31. The LibreOffice application should have a form that takes and assign the variables:
  32. @transaction_id
  33. @description
  34. @amount
  35. @debit_account_id
  36. @credit_account_id
  37. and then executes the former SQL command. How can it be done?
Advertisement
Add Comment
Please, Sign In to add comment