Stored Procedures- Getting started

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
fuzzyfuzz
Forum Newbie
Posts: 10
Joined: Fri Dec 05, 2008 5:07 pm

Stored Procedures- Getting started

Post by fuzzyfuzz »

Hi!
I'm starting to use the SP in my DB. thus, I have some questions about it:

1.I'm using WAMPSERVER- How can I access the storedProcedures from phpmyadmin?
or how can i accsess the SP I wrote at all?

2. Where do i write the SP? in php script or in the console?


This is my code- I wrote it in the php script but it doesn't work

Code: Select all

 
 
<?php
$mysql_link= mysql_connect('localhost','root','') or die("ERROR:cannot 
 
connect");
echo "connected successfully to MySQL server.";
 
mysql_select_db('pets',$mysql_link) or die ("could not open db".mysql_error());
echo "connected successfully to pets.";
DELIMITER //
CREATE PROCEDURE InsertData(IN Bname varchar(10) )
BEGIN
INSERT INTO exprience (BookNname)
VALUES (Bname);
END //
DELIMITER ;
 
CALL InsertData ('Oliver Twist');
mysql_close($mysql_link);
 
?>
 
 
Need your help!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Stored Procedures- Getting started

Post by VladSun »

You need to create the stored procedure once - in MySQL console or in a SQL query in PHP admin.
Then read this:
viewtopic.php?f=2&t=81689
There are 10 types of people in this world, those who understand binary and those who don't
eskio
Forum Commoner
Posts: 66
Joined: Tue Apr 01, 2008 1:00 am

Re: Stored Procedures- Getting started

Post by eskio »

Hi,

to create stored procedure, use MySQL console or you can download the MySQL administrator (client program) from http://dev.mysql.com/downloads/gui-tools/5.0.html
Post Reply