Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6966135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:09:09+00:00 2026-05-27T16:09:09+00:00

Environment: MySQL 5.1, Linux I have a stored procedure that computes several values from

  • 0

Environment: MySQL 5.1, Linux

I have a stored procedure that computes several values from a single input value. The values are returned as OUT parameters. I would like to call this procedure for every row set and have the values appear as columns in the result set. The values have a complex relationship such that distinct functions for each value is not easily constructed.

The question: How can I get OUT parameters to show up as columns in a table?

Here’s what I have so far:

DELIMITER $_$
DROP PROCEDURE IF EXISTS in_out;
CREATE PROCEDURE in_out (
       IN s TEXT, 
       OUT op TEXT, 
       OUT opn INT,
       OUT opd TEXT,
       OUT len INT
       )
BEGIN
        SET op = 'del';
        SET opn = 1;
        SET opd = substr(s,4);
        SET len = LENGTH(SUBSTR(s,4));
END
$_$
DELIMITER ;

Then:

mysql> call in_out('delACT',@op,@opn,@opd,@len);
Query OK, 0 rows affected (0.00 sec)

mysql> select @op,@opn,@opd,@len;
+------+------+------+------+
| @op  | @opn | @opd | @len |
+------+------+------+------+
| snv  |    1 | ACT  |    3 |
+------+------+------+------+
1 row in set (0.00 sec)

So far so good, but I can’t figure out how to call this procedure for every row and return the results in the result set. I want is something like this:

dream> select mycol,in_out(mycol) from mytable
+---------+------+------+------+------+
| mycol   | @op  | @opn | @opd | @len |
+---------+------+------+------+------+
| delACT  | del  |    1 | ACT  |    3 |
+---------+------+------+------+------+

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:09:10+00:00Added an answer on May 27, 2026 at 4:09 pm

    This appears to be a trick question: one can’t create table relations out of function/procedure results in MySQL. I ended up refactoring into separate functions (as suggested by Michał). I had been hoping for a MySQL equivalent to PostgreSQL’s table functions (http://goo.gl/77QVE).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're using MySQL with Innodb Engine storage. We have an evented environment that sends
I have config.time_zone in environment.rb set to UTC, and my mySQL server returns the
i have a LAPP (linux, apache, postgresql and php) environment, but the question is
I have php scripts that I have to run on linux as well as
I have a Spring+hibernate+mysql+jstl architecture, running in a linux CENTOS production enviroment. I added
Environment: Linux / MySQL / PHP Problem: While connected to a webservice, I am
My dev team uses WAMP for the php/Mysql environment but i just learnt that
There is site http://abc.com (made in PHP, MySQL, Apache, Linux environment). Currently, MySQL on
how in lamp (LINUX ,APACHE ,MYSQL ,PHP) environment , can i show date and
First the environment: Rails 2.1.0, Ruby 1.8.7, Mysql 5.1.54, Ubuntu 11.04 I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.