=============Stored Procedure 0======================

mysql>DELIMITER //

mysql> CREATE PROCEDURE TestSP0 ()

BEGIN

create Table Table_jdwang_PmKey(name VARCHAR(20) PRIMARY KEY, birthday Date, mobilephone VARCHAR(20)) CHARSET=utf8;

DESC Table_學號_PmKey;

INSERT INTO Table_學號 VALUES('jdwang1', '1966/7/7', '0939111222');

SELECT * FROM Table_學號_PmKey;

END

//

mysql> DELIMITER ;

mysql> SHOW CREATE PROCEDURE TestSP0;

mysql> CALL TestSP0;

 

 

 

mysql>DELIMITER //

mysql> CREATE PROCEDURE TestSP1 ()

BEGIN

SELECT * FROM Table1;

END

//

mysql> DELIMITER ;

mysql> SHOW CREATE PROCEDURE TestSP1;

mysql> CALL TestSP1;

 

=============Stored Procedure 2======================

mysql>DELIMITER //

mysql> CREATE PROCEDURE TestSP2 ( T int)

BEGIN

SELECT * FROM Table1 WHERE ? > T;

END

//

mysql> DELIMITER ;

mysql> SHOW CREATE PROCEDURE TestSP1;

mysql> CALL TestSP2;

=============Stored Procedure 3======================

mysql>DELIMITER //

mysql> CREATE PROCEDURE TestSP3 ( )

BEGIN

DECLARE r DOUBLE;

SELECT avg(FieldName) INTO r FROM Table1 ;

RETURN r;

END

//

mysql> DELIMITER ;

mysql> SHOW CREATE PROCEDURE TestSP3;

mysql> CALL TestSP2;

 

=======================================

mysql> DROP TestSP1;