Stored Procedures Help please

Reply

Join Date: Oct 2009
Posts: 4
Reputation: badmanmc is an unknown quantity at this point 
Solved Threads: 0
badmanmc badmanmc is offline Offline
Newbie Poster

Stored Procedures Help please

 
0
  #1
Nov 1st, 2009
I have made stored procedures in Oracle...but need to export them to mysql. I have searched on google but cant figure out the syntax.

Here is the oracle procedure:


  1. CREATE OR REPLACE procedure delgroup
  2. (g_id IN number)
  3.  
  4. IS
  5.  
  6. BEGIN
  7.  
  8. DELETE FROM grouptable WHERE GROUP_ID=g_id;
  9.  
  10. COMMIT;
  11. END;


I jus basically want to delete the group from the group table..depending on which group id (the arguement) the user types in.

How would i do this exact same procedure in mysql?

Please some assistance guys
Last edited by peter_budo; Nov 1st, 2009 at 4:39 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 438
Reputation: Atli is on a distinguished road 
Solved Threads: 56
Atli's Avatar
Atli Atli is offline Offline
Posting Pro in Training
 
0
  #2
Nov 1st, 2009
Hey.

You can see how MySQL procedures look like in the manual.

In your case it would look something like this:
  1. DROP PROCEDURE IF EXISTS `delgroup`;
  2. DELIMITER //
  3. CREATE PROCEDURE `delgroup`(g_id INT)
  4. BEGIN
  5. DELETE FROM grouptable WHERE GROUP_ID=g_id;
  6. END//
  7. DELIMITER ;
Note, the DELIMITER commands and the trailing // on END are only required if you are running this through the MySQL CLI, or other such interfaces.
Last edited by Atli; Nov 1st, 2009 at 1:01 pm.
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
Reply With Quote Quick reply to this message  
Reply

Message:



Other Threads in the MySQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC