Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

accessing the return value of called procedure

 
   Database Help (Home) -> mySQL RSS
Next:  views and security  
Author Message
nobody30

External


Since: Jan 15, 2005
Posts: 15



(Msg. 1) Posted: Sun Feb 13, 2005 4:40 am
Post subject: accessing the return value of called procedure
Archived from groups: mailing>database>mysql (more info?)

this is one way of creating a stored procedure in mysql:

CREATE PROCEDURE some_procedure (IN value1, OUT value2)
BEGIN
  SELECT ... INTO value2 FROM ....
END//


and if called from another procedure, i can access the variable this way:

CREATE PROCEDURE another_procedure (....)
BEGIN
  DECLARE count INT;
  ...
  CALL some_procedure(..., count);
  IF (count ... ) THEN
  END IF;
  ...
  ...
END//


there is another way of creating a stored procedure in mysql without
using a variable:

CREATE PROCEDURE some_procedure (IN value1)
BEGIN
  SELECT ... FROM ....
END//


if i were to use this way, how can i access the return value?

CREATE PROCEDURE another_procedure (....)
BEGIN
  ...
  CALL some_procedure(...); <==== how to access the value?
  ...
  ...
END//


i tried several ways:

1) SET count = CALL some_procedure(...);
2) IF ((CALL some_procedure(...)) ...) THEN

but both produce an error.

 >> Stay informed about: accessing the return value of called procedure 
Back to top
Login to vote
Bill Karwin1

External


Since: Jun 17, 2004
Posts: 42



(Msg. 2) Posted: Sun Feb 13, 2005 6:05 pm
Post subject: Re: accessing the return value of called procedure [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

- wrote:
 > i tried several ways:
 >
 > 1) SET count = CALL some_procedure(...);
 > 2) IF ((CALL some_procedure(...)) ...) THEN
 >
 > but both produce an error.

A procedure that returns a value instead of having an OUT parameter is
called a FUNCTION. This is created with the CREATE FUNCTION statement.
Functions are very similar to procedures, except that they cannot
reference any tables; that is, they can't perform queries.

Looking in the grammar source code for MySQL 5.0.2, there _appears_ to
be support for queries of the form:
SELECT * FROM PROCEDURE procname();
But I can't get it to work. It might be an unfinished feature. We are
using 5.0 alpha, after all.

Is it a problem to use a variable and fill it by passing it as an OUT
parameter to the procedure?

Regards,
Bill K.

 >> Stay informed about: accessing the return value of called procedure 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
threading of procedure - i have a stored procedure that does several things in the following order: select record do stuff with record delete record if there are multiple clients accessing the procedure, will the resultset of 'select record' differ among the clients? does..

Best way to issue hundreds of inserts/updates??? - Using mysql 4.0.23- What is the best way to execute several (hundreds of) inserts and updates? Rather than issuing tons of individual inserts and updates, can I send the strings to a text file and then have mysql do them all?? IE : query.txt insert..

MySQL freezes, brings XP machine to a grinding halt - I've been using MySQL for a while for fairly light database development on my XP machine. Currently, I am just starting a new project and have experienced some big problems with MySQL today both on my office machine and at home where running a particular...

login as user 'root' but do not have root privlages and my.. - Hi gang: I'm experiencing a problem with MySQL -- I updated MySQL from version 4.1.0 to 4.1.10 and now when I login as root it doesn't show all the databases I should have access to, nor it doesn't recognize me being logged in as root (via..

FLUSH TABLES hangs if table is locked - Using FLUSH TABLES via the C query API mysql_query() hangs if the table is locked already. That is to say, nothing prevents me from running a LOCK TABLES twice; it won't tell me "it's already locked, don't try to run a FLUSH". Anyone know ...
   Database Help (Home) -> mySQL All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]