Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored procedure in MySQL5

Status
Not open for further replies.

NewbiDoobie

Technical User
Jul 25, 2005
63
US
I am writing this stored procedure and it keeps erroring out:
Code:
create procedure RetensionRate ()
BEGIN
CREATE TEMPORARY TABLE mytemptable (Week int,  beginning_Count bigint, Ending_Count bigint, Retension_Rate decimal);

insert into mytemptable select Week,  Beginning_Count,Ending_Count, Retension_Rate * 100 from RetensionSummary order by week;

select * from mytemptable;
END

the error I keep getting is:


Failed to execute SQL : SQL create procedure RetensionRate () BEGIN CREATE TEMPORARY TABLE mytemptable (Week int, beginning_Count bigint, Ending_Count bigint, Retension_Rate decimal); insert into mytemptable select Week, Beginning_Count,Ending_Count, Retension_Rate * 100 from RetensionSummary order by week; select * from mytemptable; END failed : 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 'CREATE TEMPORARY TABLE mytemptable (Week int, beginning_Count bigint, Ending_Co' at line 1



This seems to happen every time I use a begin and end statement as the statements run fine until I try to place this into a procedure

 
I can't understand why that doesn't work (assuming you're using MySQL 5.0). However, in your example, you do realise that a temporary table is unnecessary?
 
I realize it is, however it is the starting for a long SP I an transfering from SQL server. There will be updates and modifications to the table, etc...

I did check the verion and I can creat a simple SP, however when I add a begin/end it goes haywire
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top