Geeks Talk

Prepare for your Next Interview




Stored Procedure problem...

This is a discussion on Stored Procedure problem... within the MY SQL forums, part of the Databases category; This is my stored procedure but it is not working ... CREATE PROCEDURE sp_select_custId (IN custId INTEGER) BEGIN select * from customer c,tapedelivery t where c.CustomerID=t.CustomerId And c....


Go Back   Geeks Talk > Databases > MY SQL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-11-2007
Contributing Member
 
Join Date: Sep 2006
Location: bangalore, india
Posts: 1,007
Thanks: 0
Thanked 71 Times in 60 Posts
psuresh1982 will become famous soon enough
Stored Procedure problem...

This is my stored procedure but it is not working ...

CREATE PROCEDURE sp_select_custId (IN custId INTEGER)
BEGIN
select * from customer c,tapedelivery t where c.CustomerID=t.CustomerId And c.CustomerID = custId;
END;

But it is not running ..it is giving error ..please suggest me correct syntax/way to create this procedure
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-12-2007
Expert Member
 
Join Date: Jun 2006
Location: India
Posts: 411
Thanks: 15
Thanked 32 Times in 24 Posts
jamesravid is on a distinguished road
Re: Stored Procedure problem...

If i am not wrong you can't use "select...from" clause with in a procedure.
Instead you can either use cursors (for multiple records) or "select...into...from"(for single row) clause.

We have this rule in Oracle. I think it is also applicable to MY SQL as well.

correct me if i am wrong
__________________
Cheers,
:) James:)

Last edited by jamesravid : 08-03-2007 at 07:16 AM.
Reply With Quote
  #3 (permalink)  
Old 10-17-2007
Expert Member
 
Join Date: Apr 2007
Posts: 404
Thanks: 13
Thanked 52 Times in 52 Posts
susarlasireesha is on a distinguished road
Re: Stored Procedure problem...

mysql> DELIMITER |
mysql> CREATE PROCEDURE emp_test()
-> BEGIN
-> DECLARE x INT;
-> DECLARE y VARCHAR(25);
-> SELECT empno,empname INTO x,y FROM emp LIMIT 1;
-> SELECT x,y;
-> END|
Query OK, 0 rows affected (0.00 sec)

mysql> DELIMITER ;
mysql> CALL emp_test()\G

I think this example help u.....
To know more about it user this link mysql
Reply With Quote
  #4 (permalink)  
Old 12-10-2007
Junior Member
 
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
vijaya_pitta is on a distinguished road
Re: Stored Procedure problem...

hi, try this , it will run

CREATE PROCEDURE sp_select_custId ( custId INT)
BEGIN
select * from customer c,tapedelivery t where c.CustomerID=t.CustomerId And c.CustomerID = custId;
END;








Quote:
Originally Posted by psuresh1982 View Post
This is my stored procedure but it is not working ...

CREATE PROCEDURE sp_select_custId (IN custId INTEGER)
BEGIN
select * from customer c,tapedelivery t where c.CustomerID=t.CustomerId And c.CustomerID = custId;
END;

But it is not running ..it is giving error ..please suggest me correct syntax/way to create this procedure
Reply With Quote
Reply

  Geeks Talk > Databases > MY SQL


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Reg:Stored Procedure chakravarthy_info Data Warehousing 1 02-14-2008 12:07 PM
Simple example of Oracle Stored Procedure mann_se Oracle 2 07-07-2007 02:02 AM
implementation of stored procedure sreenivasamurthy Data Warehousing 0 06-20-2007 08:59 AM
Extended Stored Procedure venkat_1984 SQL Server 1 06-16-2007 04:45 PM
Create and run the stored procedure sm_amuda ASP.NET 2 04-14-2007 07:15 AM


All times are GMT -4. The time now is 02:05 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved