The ALTER statement lets you change the characteristics of a stored procedure : Procedure « Procedure Function « MySQL Tutorial

MySQL Tutorial
1. Introduction
2. Select Query
3. Database
4. Table
5. Table Join
6. Subquery
7. Insert Update Delete
8. Logic Operator
9. View
10. Data Types
11. Procedure Function
12. Cursor
13. Trigger
14. Date Time Functions
15. Comparison Functions Operators
16. Aggregate Functions
17. Cast Functions Operators
18. Control Flow Functions
19. Encryption Compression Functions
20. Information Functions
21. Math Numeric Functions
22. Miscellaneous Functions
23. String Functions
24. Regular Expressions
25. Data Dictionary
26. MySQL Utilities
27. Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
MySQL Tutorial » Procedure Function » Procedure 
11. 5. 8. The ALTER statement lets you change the characteristics of a stored procedure

It has the following syntax:

ALTER PROCEDURE [<database>.]<procedure name> <characteristics>

The ALTER statement can change any of the characteristics used to create the procedure.

The following example changes the SQL SECURITY and COMMENT on the myProc procedure.

mysql>
mysql> DELIMITER //
mysql> CREATE PROCEDURE myProc (IN in_count INT)
    -> BEGIN
    ->     DECLARE count INT default 0;
    ->
    ->     increment: LOOP
    ->     SET count = count + 1;
    ->     IF count < 20 THEN ITERATE increment; END IF;
    ->     IF count > in_count THEN LEAVE increment;
    ->     END IF;
    ->     END LOOP increment;
    ->
    ->     SELECT count;
    -> END
    -> //
Query OK, rows affected (0.00 sec)

mysql> DELIMITER ;
mysql>
mysql> call myProc(5);
+-------+
| count |
+-------+
|    20 |
+-------+
row in set (0.02 sec)

Query OK, rows affected (0.02 sec)

mysql>
mysql>
mysql> ALTER PROCEDURE myProc SQL SECURITY INVOKER
    ->   COMMENT 'This is my procedure';
Query OK, rows affected (0.00 sec)

mysql>
mysql>
mysql> SELECT FROM mysql.proc WHERE name = 'myProc'\G
*************************** 1. row ***************************
              db: test
            name: myProc
            type: PROCEDURE
   specific_name: myProc
        language: SQL
 sql_data_access: CONTAINS_SQL
is_deterministic: NO
   security_type: INVOKER
      param_list: IN in_count INT
         returns:
            bodyBEGIN
    DECLARE count INT default 0;

    increment: LOOP
    SET count = count + 1;
    IF count < 20 THEN ITERATE increment; END IF;
    IF count > in_count THEN LEAVE increment;
    END IF;
    END LOOP increment;

    SELECT count;
END
         definer: root@localhost
         created: 2007-07-23 18:58:35
        modified: 2007-07-23 18:58:35
        sql_mode:
         comment: This is my procedure
row in set (0.00 sec)

mysql>
mysql> drop procedure myProc;
Query OK, rows affected (0.00 sec)

mysql>
mysql>
11. 5. Procedure
11. 5. 1. The CREATE PROCEDURE Statement
11. 5. 2. You can set parameters for a stored procedure
11. 5. 3. Using an OUT parameter.
11. 5. 4. The stored procedure characteristics include a number of options for how the stored procedure behaves.
11. 5. 5. Creating a Single-Statement Procedure
11. 5. 6. Calling a Single-Statement Procedure
11. 5. 7. Creating a Multistatement Stored Procedure
11. 5. 8. The ALTER statement lets you change the characteristics of a stored procedure
11. 5. 9. To remove a stored procedures, use the DROP statement
11. 5. 10. ALTER PROCEDURE and ALTER FUNCTION Syntax
11. 5. 11. DROP PROCEDURE and DROP FUNCTION Syntax
11. 5. 12. Stored Procedure Permissions
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.