CREATE PROCEDURE syntax
CREATE
[DEFINER = { user | CURRENT_USER }]
PROCEDURE sp_name ([proc_parameter[,...]])
[characteristic ...] routine_body
proc_parameter:
[ IN | OUT | INOUT ] param_name type
CREATE FUNCTION syntax
CREATE
[DEFINER = { user | CURRENT_USER }]
FUNCTION sp_name ([func_parameter[,...]])
RETURNS type
[characteristic ...] routine_body
func_parameter:
param_name type
CREATE PROCEDURE and CREATE FUNCTION require the CREATE ROUTINE privilege. They might also require the SUPER privilege, depending on the DEFINER value.
DROP PROCEDURE and DROP FUNCTION Syntax: this statement is used to drop a stored procedure or function.
DROP {PROCEDURE | FUNCTION} [IF EXISTS] procedure_or_function_name
Specifying a parameter as IN, OUT, or INOUT is valid only for a PROCEDURE. For a FUNCTION, parameters are always regarded as IN parameters. An IN parameter passes a value into a procedure. An OUT parameter passes a value from the procedure back to the caller. Its initial value is NULL within the procedure, and its value is visible to the caller when the procedure returns. An INOUT parameter is initialized by the caller, can be modified by the procedure, and any change made by the procedure is visible to the caller when the procedure returns.
Lets see a simple stored procedure using OUT parameter:
CREATE PROCEDURE jumlah( out juml int ) BEGIN SELECT count( * ) INTO juml FROM FUNCTIONS; END
Note: The example uses the mysql client delimiter command to change the statement delimiter from ; to // while the procedure is being defined. This allows the ; delimiter used in the procedure body to be passed through to the server rather than being interpreted by mysql itself.
And now how to CALL the procedure? Lets see this query:
CALL jumlah(@a); SELECT @a ;
If you want to see the that procedure is exists on your server, you can try to Export as a sql and check the structure especially Add CREATE PROCEDURE / FUNCTION. On the bottom you will see the procedure you have been created:
–
– Procedures
–
DELIMITER $$
–
CREATE DEFINER=`root`@`localhost` PROCEDURE `jumlah`( out juml int )
BEGIN SELECT count( * )
INTO juml
FROM FUNCTIONS;
END$$
–
DELIMITER ;
–
And then the syntax to drop the procedure if you want to trash it:
DROP PROCEDURE IF EXISTS jumlah
Lets see a simple function:
CREATE FUNCTION fungsi( aCHAR( 10 ) ) RETURNS CHAR( 20 ) DETERMINISTIC RETURN CONCAT( 'Fungsi, ', a, '.' ) ;
Then try to execute that query like this to see the result:
SELECT fungsi('test only');
Like procedure above you can see the function by Export as sql and the bottom look view:
CREATE DEFINER=`root`@`localhost` FUNCTION `fungsi`(a CHAR(10)) RETURNS char(20) CHARSET latin1
DETERMINISTIC
RETURN CONCAT(‘Fungsi, ‘,a,’.')
And then the syntax to drop the procedure if you want to trash it:
DROP FUNCTION IF EXISTS fungsi
Well improve your self with aother case and develop yours.

99 Trackbacks / Pingbacks for this entry:
Purchase@Albenza.Online” rel=”nofollow”>……
Buydrugs without prescription ttp…
hair@growth.and.accutane” rel=”nofollow”>..…
Buygeneric drugs…
acomplia@sleep.apnea” rel=”nofollow”>.…
Buygeneric drugs…
altace@cough.buy” rel=”nofollow”>..…
Buynow…
aciphex@muscle.pain” rel=”nofollow”>..…
Buygeneric pills…
actos@side.effects.edema” rel=”nofollow”>..…
Buygeneric drugs…
how@to.monitor.anafranil” rel=”nofollow”>.…
Buyno prescription…
antidepressant drugs for cats…
Buy_generic drugs…
alberta alcohol and drug abuse commission…
Buy_generic meds…
drug detection testing…
Buy_generic meds…
recipes for gastric bypass patients…
Buy_now…
citalopram length of use…
Buy_drugs without prescription…
best life diet…
Buy_no prescription…
weight gain stories feeders…
Buy_drugs without prescription…
accutane birth defects…
Buy_it now…
menstrual patterns in menopause…
Buy_no prescription…
dependent disorder anxiety…
Buy_generic pills…
bmi chart for kids…
Buy_generic drugs…
herbal flee collars for dogs…
Buy_generic pills…
buy cheap clomid…
Buy_it now…
statistics on pregnancy in high school…
Buy_generic meds…
what is valtrex used for…
Buy_generic drugs…
cures for fingernail fungi…
Buy_generic meds…
symptoms of chocolate allergy…
Buy_it now…
deadliest type of cancer…
Buy_generic pills…
bacterial staphylococcus aureus meningitis symptoms…
Buy_without prescription…
genie francis weight loss…
Buy_now…
st joseph aspirin coupon…
Buy_generic pills…
persistent nausea and stomach pain…
Buy_generic meds…
cordarone intravenous…
Buy_generic meds…
respiratory infection humidity dry antibiotics avelox…
Buy_generic pills…
find clomid cheap in us…
Buy_now…
hot spots or cancer…
Buy_without prescription…
south beach diet foods to avoid…
Buy_no prescription…
what causes constant itching…
Buy_generic pills…
washington university marfan losartan study…
Buy_drugs without prescription…
clinical trial ediary data…
Buy_now it…
juliet’s on the spot acne treatment…
Buy_drugs without prescription…
altitude and pregnancy…
Buy_it now…
glucophage powered by vbulletin version 2.2.1…
Buy_generic pills…
neurontin and mood lability…
Buy_generic meds…
menses while on birth control pills…
Buy_generic drugs…
medical nebulizer…
Buy_generic meds…
can iodine help thyroid function…
Buy_generic drugs…
breven medication for add…
Buy_generic drugs…
drug citalopram side effects…
Buy_generic drugs…
information about treatment for leg edema…
Buy_generic drugs…
air purifiers for allergies…
Buy_generic meds…
dogs to detect cancer…
Buy_generic drugs…