MySQL Forums
Forum List  »  Stored Procedures

Table Reference on Update Statement
Posted by: Jim Frith
Date: July 30, 2019 06:52PM

I am getting a "No Database Selected" error on an update statement where I have specifically referenced the table. e.g. UPDATE mydb.mytable. The update runs correctly if I have a default database set.

I am accessing two different databases in the procedure.

I am also using prepared statements and the database names are stored in session variables.

I cannot set the default database with a "USE" statement since it is not supported in prepared statements.
eg. SET @qry := CONCAT("USE ",@src_db) cannot be prepared.

Is there a way to specifically reference the database.tablename in an Update statement?

Options: ReplyQuote

Written By
Table Reference on Update Statement
July 30, 2019 06:52PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.