Hello,
I am trying to eliminate the need for creating multiple Routines which are doing the same thing on different databases.
I would like to use the "USE DB1;" syntax at the beginning of a routine to determine which database to look at. Each database has the same structure (Tables/Views) are identical. However the data stored within the tables are different.
Is it possible to use a CASE statement to determine which database to look at?
i.e.
Case
when Client = XXX then USE db1
when Client = YYY then USE db2
when Client = ZZZ then USE db3
Else USE db4
END
After the database to use is identified, it will run the routine against that DB and retrieve the results respectively.
Is this possible?
Thanks,
Charlie (MySQL Rookie)
I am trying to eliminate the need for creating multiple Routines which are doing the same thing on different databases.
I would like to use the "USE DB1;" syntax at the beginning of a routine to determine which database to look at. Each database has the same structure (Tables/Views) are identical. However the data stored within the tables are different.
Is it possible to use a CASE statement to determine which database to look at?
i.e.
Case
when Client = XXX then USE db1
when Client = YYY then USE db2
when Client = ZZZ then USE db3
Else USE db4
END
After the database to use is identified, it will run the routine against that DB and retrieve the results respectively.
Is this possible?
Thanks,
Charlie (MySQL Rookie)