» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > MySQL Forums

MySQL Forums Share Your Ideas and Tips about MYSQL. Ask questions about MYSQL. Table Design and Much More...

Reply
 
Thread Tools Display Modes
  #1  
Old 09-06-2006, 08:42 AM
silvair silvair is offline
Junior Member
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
silvair is on a distinguished road
Default How to use CREATE PROCEDURE?

Hi All,
How to use CREATE PROCEDURE, and I do not understand the distinction between a script and a query. I wrote this small script:

CREATE PROCEDURE SimpleProc (OUT outCount INTEGER)
BEGIN
SELECT COUNT(*) INTO outCount FROM searches;
END

On executing the script I get the baffling error message: "Line 1; 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 'SELECT COUNT (*) INTO outCount FROM searches' at line 3; ErrorNr. 1064". However, if I open up a query and copy in the exact same text I get the message: "Query returned no resultset", i.e. the call to CREATE PROCEDURE was successful.

Why should the same piece of SQL work as a query and fail as a script? any idea? -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 09-06-2006, 08:44 AM
rian rian is offline
Senior Member
 
Join Date: Jul 2006
Posts: 135
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 18
rian is on a distinguished road
Default

it's the result of a certain metapher used here. The default delimiter for queries is the semicolon so QB assumes your query ends after "... from searches;" which is obviously wrong. What you therefore need is temporarily setting a different delimiter (e.g. $), e.g.:

delimiter $
CREATE PROCEDURE SimpleProc (OUT outCount INTEGER)
BEGIN
SELECT COUNT(*) INTO outCount FROM searches;
END$
delimiter ; -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
create index!! Drichek MySQL Forums 1 11-23-2006 05:12 AM
stored procedure creating problem? Wumchi MySQL Forums 1 11-23-2006 04:57 AM
to create indexing!!! paoli MySQL Forums 1 09-18-2006 07:36 AM
to store procedure via Admin?? Kenedi MySQL Forums 1 08-21-2006 05:51 AM
create the Custom Datatype in MySQL dominic MySQL Forums 1 08-08-2006 02:10 PM


All times are GMT. The time now is 05:45 AM.