I’m trying to program a database, and I’m using a mix of parameterized queries and stored procedures. Mostly I’m using pqs inside sprocs. I’m doing each correctly, and getting the proper results. However, each time I log out of the mysql server and back in, the sprocs are still there, but it acts like I never programmed any pqs. It only works if I do the pqs all over again from scratch. I haven’t seen anything either in lectures or online about pqs being temporary, so is there something I’m doing wrong? Thank you.
Share
You have an apples-and-asterisks category confusion.
Apples: Stored procedures are persistent server-side objects with names in the name space of a particular MySQL database. Just like table definitions, views, and table contents, they are part of your database.
Asterisks: Parameterized queries (prepared statements) are client-side objects that are created underneath a particular connection to the DBMS. They’re objects in the class hierarchy of whatever connection library (in whatever language) you happen to be using. Their lifetimes cannot exceed the lifetime of the connection.
If your app happens to be using more than one connection (for example, if it’s multithreaded) you need to create your parameterized query for the particular connection you’re using.