IT Community - Software Programming, Web Development and Technical Support

Procedure Function

This is a discussion on Procedure Function within the Database Support forums, part of the Web Development category; Begin End Examples mysql> mysql> DELIMITER // mysql> CREATE FUNCTION myProcedure (rate DECIMAL(10,2)) -> RETURNS DECIMAL(...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Database Support

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 11-09-2007, 06:05 AM
varghese varghese is offline
D-Web Programmer
 
Join Date: Feb 2007
Posts: 93
varghese is on a distinguished road
Default Procedure Function

Begin End Examples
mysql>
mysql> DELIMITER //
mysql> CREATE FUNCTION myProcedure (rate DECIMAL(10,2))
-> RETURNS DECIMAL(10,2)
->
-> SQL SECURITY DEFINER
->
-> tax: BEGIN
-> DECLARE discount DECIMAL(10,2);
-> SET discount = rate * .05;
-> RETURN discount;
-> END
-> //
Query OK, 0 rows affected (0.00 sec)

mysql> DELIMITER ;
mysql>
mysql> select myProcedure(123.45);
+----------------+
| myProcedure(123.45) |
+----------------+
| 6.17 |
+----------------+
1 row in set, 1 warning (0.00 sec)

mysql>
mysql> drop function myProcedure;
Query OK, 0 rows affected (0.00 sec)

mysql>
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-10-2007, 01:17 AM
Murali Murali is offline
D-Web Master
 
Join Date: Feb 2007
Location: India-Chennai.
Posts: 386
Murali is on a distinguished road
Send a message via AIM to Murali
Default Re: Procedure Function

Quote:
Originally Posted by varghese View Post
Begin End Examples
mysql>
mysql> DELIMITER //
mysql> CREATE FUNCTION myProcedure (rate DECIMAL(10,2))
-> RETURNS DECIMAL(10,2)
->
-> SQL SECURITY DEFINER
->
-> tax: BEGIN
-> DECLARE discount DECIMAL(10,2);
-> SET discount = rate * .05;
-> RETURN discount;
-> END
-> //
Query OK, 0 rows affected (0.00 sec)

mysql> DELIMITER ;
mysql>
mysql> select myProcedure(123.45);
+----------------+
| myProcedure(123.45) |
+----------------+
| 6.17 |
+----------------+
1 row in set, 1 warning (0.00 sec)

mysql>
mysql> drop function myProcedure;
Query OK, 0 rows affected (0.00 sec)

mysql>
I worked out same code given, but returns with error

Code:
This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
May be here is suitable syntax for creating a stored function,

Code:
DROP FUNCTION IF EXISTS myProcedure;
CREATE FUNCTION myProcedure (rate DECIMAL(10,2)) RETURNS DECIMAL(10,2)
	DETERMINISTIC
	COMMENT 'Simple Function'
 	SQL SECURITY DEFINER
BEGIN
	DECLARE discount DECIMAL(10,2);
	SET discount = rate * .05;
RETURN discount;
END;
__________________
-Murali..

Last edited by Murali : 11-10-2007 at 01:19 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create store procedure? senraj Database Support 4 04-25-2008 06:26 AM
stored procedure itbarota Database Support 3 03-10-2008 09:43 PM
how to get out parameter of stored procedure ? Murali PHP Programming 0 12-16-2007 04:57 AM
Can a stored procedure call itself or recursive stored procedure? How many level SP n H2o Database Support 1 08-03-2007 10:55 AM
Diff inline function and ordinary function vigneshgets C and C++ Programming 1 05-24-2007 11:34 AM


All times are GMT -7. The time now is 07:02 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0