List:General Discussion« Previous MessageNext Message »
From:Rory McKinley Date:February 10 2006 7:40am
Subject:Re: [SOLVED]Passing db names to a stored proc in MySQL 5
View as plain text  
<snip>
> You were so close! Try it more like this:
> 
> SET sSQL=CONCAT('SELECT * FROM ', passed_in_db_name, '.sites WHERE 
> site_name=?');
> 
> PREPARE query_statement from sSQL
<snip>

Yup - got it to work - but it is so much hassle that I might seriously 
reconsider having queries run across databases, as it works fine for one 
or two stored procs, but I really cannot imagine doing hundreds this 
way! Only change I had to make was to put the @ in front of the variable 
name otherwise the prepare statement bombs!

Thanks Shawn and Martijn for the help

Thread
Passing db names to a stored proc in MySQL 5Rory McKinley9 Feb
  • Re: Passing db names to a stored proc in MySQL 5Martijn Tonies9 Feb
    • Re: Passing db names to a stored proc in MySQL 5Peter Brawley12 Feb
  • Re: Passing db names to a stored proc in MySQL 5SGreen9 Feb
    • Re: Passing db names to a stored proc in MySQL 5Martijn Tonies9 Feb
    • Re: Passing db names to a stored proc in MySQL 5Rory McKinley9 Feb
      • Re: Passing db names to a stored proc in MySQL 5SGreen9 Feb
        • Re: Passing db names to a stored proc in MySQL 5Rory McKinley10 Feb
        • Re: [SOLVED]Passing db names to a stored proc in MySQL 5Rory McKinley10 Feb
      • Re: Passing db names to a stored proc in MySQL 5Peter Brawley11 Feb