0

I want to store the output from a PROCEDURE into a global userdefined VAR so i can use this "list" in an other PROCEDURE on a different database.

Second, if the VAR is used on the 2nd PROCEDURE it should be unset, because on next CALL it will append or?

Thanks for response!

BEGIN
SELECT `steamid` FROM `mybb_users` WHERE `steamid`!='';
END

The SELECT shout go into a global variable, so i can use the result in another procedure...

1

1 Answer 1

1

As far as I know, you can't return a row set as a result of a procedure in MySQL.

I would solve it by creating a temporary table in the first procedure, and then use that temp table in the second procedure. Something like this:

delimiter $$
create procedure procedure1()
begin
    drop table if exists temp_table;
    create temporary table temp_table
        select steamid from mybb_users where steamid != '';
    -- add the appropriate indexes here
    -- alter table temp_table
    --     add index ...
end $$
create procedure procedure2()
begin
    -- Do whatever you want to do with temp_table
end $$
delimiter ;

Remember:

  • A temporary table is visible only to the connection that created it.
  • If the connection is closed, the temporary table will be deleted.
  • Temporary tables are created directly to RAM (if they are not very big), so they can be pretty fast to read.
  • Each connection can create temporary tables with the same name, as each connection will have a "copy" of that temp table.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.