Connecting Tech Pros Worldwide Help | Site Map

Select/update in MySQL Stored Procedure

Newbie
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 8
#1: Feb 13 '08
I'm sorry if this is a really stupid question, but I have just started using mySQL.

I have created a basic stored proc, which does the following:

SELECT * from members;

I can call it from mySQL Query Browser and return the results, but the recordset can't be edited.

Is there any way that the results from a stored procedure can be directly edited, or should I be using views?

Thanks
Penny
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#2: Feb 14 '08

re: Select/update in MySQL Stored Procedure


Questions are not stupid, answers can.

A SELECT is just a read from a table. To update a table you need an INSERT (new row) or an UPDATE (existing row). You can do these from within a stored proc, but you'll have to write the logic for that within the proc.

In short: you cannot just 'save' the result set of a SELECT, inside or outside a stored proc.

Ronald
Newbie
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 8
#3: Feb 15 '08

re: Select/update in MySQL Stored Procedure


Thank you for clearing that up for me.

I really appreciate it.

Penny
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#4: Feb 15 '08

re: Select/update in MySQL Stored Procedure


Quote:

Originally Posted by Penstar

Thank you for clearing that up for me.

I really appreciate it.

Penny

You are welcome and we'll see you again.

Ronald
Reply