Your Open Source

 
Related Posts

Stored Procedure / Views / Trigger

whats Stored Procedure / Views / Trigger ?


Stored Procedure :

A stored procedure is simply a procedure that is stored on the database server. call the procedure name to access the function

ex:

mysql> CREATE PROCEDURE test() SELECT 'test';


call the procedure:

mysql> CALL molo()\G




TRIGGER :




ex:
mysql> CREATE TABLE account (acct_num INT, amount DECIMAL(10,2));
Query OK, 0 rows affected (0.03 sec)

mysql> CREATE TRIGGER ins_sum BEFORE INSERT ON account
-> FOR EACH ROW SET @sum = @sum + NEW.amount;
Query OK, 0 rows affected (0.06 sec)

mysql> SET @sum = 0;
mysql> INSERT INTO account VALUES(137,14.9,(141,1937.50),(97,-100.00);
mysql> SELECT @sum AS 'Total amount inserted';
+-----------------------+
| Total amount inserted |
+-----------------------+
| 1852.48 |
+-----------------------+

  • hits 788
  • datetime Oct 29 08 08:57:03
  • author Damu
  • rating

Rating : 12345
Tags :- MYSQL

Answers

No Answers..
Your Name:
Your Answers :
<> is a code tag
Preview
Enter the verification code: