473,783 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to write stored procedures in mysql?

40 New Member
1. i want to write a stored procedure using mysql 5.0.45 version.

2. when i tried with the following code ,i am unable to write
Expand|Select|Wrap|Line Numbers
  1. mysql->delimeter//
  2.          ->create procedure proc(out p1 int)
  3.          ->select count(*) into p1 from emp;
  4.  
when i pressed enter, the following error is appeared .
Expand|Select|Wrap|Line Numbers
  1. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
  2. corresponds to your MySQL server version for the right syntax to use near 'delim
  3. eter//
  4. create procedure proc(out p1 int)
  5. select count(*) into p1 from emp' at line 1
  6.  
3.i even checked the manual of mysql 5.0 ver
the syntax is right


please,someone help me in this problem....
Jul 15 '08 #1
3 6156
Atli
5,058 Recognized Expert Expert
Hi.

That particular problem would be that there is no space between the DELIMITER command and the parameter you are passing it.

I would also guess that the fact you didn't end the procedure with a END would cause a problem later on.

Check out the correct syntax for stored procedures in the manual. (The two examples right above the user comments show it very well.)
Jul 16 '08 #2
shivapadma
40 New Member
when i tried with the following code the procedure got executed

mysql->create procedure proc(inout n int,out p int)
set m=n+1;

mysql->set @n=5;
mysql->call proc(@n,@m);
mysql->select @n,@m;

the output is @n @m
5 6


but when iam using begin statement with the following code,i am getting error

mysql->create procedure proc(inout n int m,out p int)
->begin
->set m=n+1;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'out p
int' at line 2


if someone knows what is the error please,kindly help me....
Jul 16 '08 #3
amitpatel66
2,367 Recognized Expert Top Contributor
This should help!! .
Jul 16 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1821
by: Chrisbarbers | last post by:
--part1_108.256bef7d.2c5af59f_boundary Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Hi =A0 I have purchased a package that uses ASP and SQL, my webhost provides MYSQL=20 and I have loaded my access database and all seems to be working fine.=20
3
2088
by: Ben | last post by:
Dear MySQL experts, I have a website that is using MS SQL Server 2000 with ASP scripting. I want to switch over to MySQL, but I'm just sticking my toes in the water at the moment to see if it makes sense. One of my favorites things about MS SQL is being able to use the Enterprise Manager as a GUI in constructing VIEWS that I later turn into stored procedures. EM makes it super simple to link tables and create a query. It basically...
3
1969
by: Marty | last post by:
Is there an issue with stored procedure and mySQL v5.0.18 ? We are programming an application that need stored procedures and triggers and our programmer can't make them work, is it a know issue or our programmer missed something? Regards, Marty
1
1591
by: E.T. Grey | last post by:
Hi All, Despite spending the past six to seven hours perusing the docs on the mySQl site, I still have questions unanswered, and have been unable to get any help. I am familiar with Sybase, some Oracle and PostgreSQL - but the mySQL SQL seems a bit "non-standard". I would be very grateful for any help I get in answering these questions: Stored procedures
2
6122
by: bshumsky06 | last post by:
Hi, I am trying to create stored procedures in MySQL. Does anyone have a suggestion on a good IDE to use. I have been working with the MySQL Query Browser but it generates errors very often and is shut down by Windows. When I make changes to my procedure, it doesn't seem to always change what is being executed. Furthermore, sometimes the procedure just disappears from my database. I am starting to think that the stored procedure...
1
10119
by: Radhakrishnans | last post by:
hai friends i am new to java and mysql.i have created stored procedures in mysql.Now i want to call that stored procedures in java.All works fine.but it show the following error. unreported exception java.lang.InstantiationException; must be caught or declared to be thrown Class.forName ("com.mysql.jdbc.Driver").newInstance(); I need code sample along with connection string.please.... My codings here CallableStatement proc =...
0
1735
by: Bruno Barberi Gnecco | last post by:
I'm using stored procedures in a PHP site, with mysql. I'm having problems with stored procedures. Of the two I'm using, one works all the time, consistently. The other works correctly, but the next query returns "Lost connection to MySQL server during query" and subsequently: "MySQL server has gone away". I'm using MDB2 to access the database. I tried changing the driver from 'mysql' to 'mysqli', with little success. Currently, about...
3
1984
by: menmysql | last post by:
i am using mysql 4.17 and i heard abt it not supporting stored procedures. plz tell me how to excute stored procedres in my system
7
5842
by: eholz1 | last post by:
Hello PHP group, Could someone help me out? I have PHP 5.2, Apache 2.0, and MySQL 5.0 running on Linux (Redhat Fedora Core 6). All that works fine. I would like to be able to "call" a stored procedure from a PHP program, and run a stored procedure. I have yet to figure out the proper way to do this. My stored procedures work fine from the mysql command line using syntax: "call sp_min_record (101);"
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.