Close   

Admin and announcement forums

    30 Mar 2008
Stored procedures in mysql 5.0.x  
kumar rakesh
create and manage free online surveys with unlimited responses
Online surveys are now basic requirement of everyone who want to review there products or to make studies about anything. But finding a solution who can provide esurveys efficiently is really a big pain. creating an online survey with inefficient tool as irritating and getting survey conducted with limitations on responses is even worse.
cont..
    30 Mar 2008
Stored procedures in mysql 5.0.x  
kumar rakesh
practice interviews and prepare for interviews
in todays changing world every one want to increase there salaries very quickly.
Changes your employer is an very efficient solution for this. But changing employer and company is not so easy.

cont..

Viewed 421 times
Total posts : 2

    04 Jan 2008
Stored procedures in mysql 5.0.x  
kumar rakesh
His other forums
Stored procedures in mysql 5.0.x
Stored procedures, trigers, views functions are new additions in mysql version 5.0.x
Here is the document that explains well, all the new additions and stored procedures in mysql.
It will surely help in getting the concepts of stored procedures and it will also help you in porting your stored procedure from SQL to MySql.
11 Jan 2008
 
kumar rakesh
His other forums
Some Facts about stored procedures in MYSQL



Stored procedures and functions


 



  1. Stored procedure list can be viewed by

    1. Show procedure status



  2. Stored procedures are case insensitive

  3. Maximum length for a stored procedure and stored function is 64 chars

  4. Stored procedures can not be nested. That is one stored procedure can not declare any other stored procedure in it’s body.

  5. Valid parameter type for stored procedures are

    1. IN – this is the default parameter type

    2. OUT

    3. INOUT



  6. session variables in mysql starts with @ and we don’t need to declare them before setting values to  them.

  7. Variable declaration in an SP

    1. DECLARE var int DEFAULT 5;

    2. DECLARE var int(20)



  8. Loops in Stored procedures

    1. IF   THEN  ELSE  END IF

    2. WHILE   END WHILE

    3. LOOP    END LOOP

    4. REPEAT  UNTIL      END REPEAT



  9. default value for an un initialized variable is NULL and NULL + 1 = NULL

  10. Calling a stored procedure from command prompt

    1. Call stpName(param);




11. stored procedure that will be called from command prompt can return any no. of values but stored procedure that will be called from some scripting language like php


can return only on value. In such stored procedures “select” query must have in INTO statement that can assign value to the variable passed as OUT variable for example 


/*


create procedure temp(OUT var varchar(255))


begin


select user from users where id=1 limit 1 into var;


end


*/

 


now to use it from php

 


$q = “call temp(@tt)”;


mysql_query($q);


$q = “select @tt”;


$r = mysql_query($q);


$row = mysql_fetch_array($r)


$row[@tt] = ‘name’;

Login to participate in forums
12 Jan 2008
 
kumar rakesh
His other forums
How will you make stored procedure which takes table name is input??



here's how you can do this.

this can be done by using dynamic sql in stored procedures.



//--------- code -------------------//

CREATE PROCEDURE get_data(IN tbl char(55))

begin



SET @s = CONCAT("select * from ",tbl , " limit 100;");

PREPARE stmt FROM @s;

EXECUTE stmt;

end



//------------ code ends -------------//
Login to participate in forums

Login to participate in forums
jump to :
Post reply on this forum

1

Comment on this forum
Name :
Email :
Comments :
Legends
Stored procedures in mysql 5.0.x Forums tagged Stored procedures in mysql 5.0.x Forums tagged. But locked for further reply
="Stored Forums locked. can not accept further replies Stored procedures in mysql 5.0.x General forum