Last active
February 7, 2017 03:33
-
-
Save enujo/4edff74ebe16b30ca1653aa67828d45b to your computer and use it in GitHub Desktop.
mySql make procedure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DELIMITER $$ | |
| DROP PROCEDURE IF EXISTS insertRent$$ | |
| CREATE PROCEDURE insertRent(libmemberNo INT(11), bookNo INT(11), payTotal INT(30),bookState VARCHAR(5)) | |
| BEGIN | |
| INSERT INTO book_rent( | |
| libmember_no, | |
| book_no, | |
| brent_start | |
| ) VALUES ( | |
| libmemberNo, | |
| bookNo, | |
| NOW() | |
| ); | |
| INSERT INTO pay( | |
| libmember_no, | |
| brent_no, | |
| pay_total | |
| ) values ( | |
| libmemberNo, | |
| LAST_INSERT_ID(), | |
| pay_total | |
| ); | |
| UPDATE book A INNER JOIN book_rent B | |
| ON A.book_no = B.book_no | |
| SET A.book_stte = bookState; | |
| END$$ | |
| DELIMITER $$ | |
| -- 생성된 프로시저 호출 | |
| call insertPay(값,값,값,값); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment