php - how to create a stored procedure in mysql the right way -
php mysqli quickguide stored procedures, http://php.net/manual/en/mysqli.quickstart.stored-procedures.php :
if (!$mysqli->query("drop procedure if exists p") || !$mysqli->query("create procedure p(in id_val int) begin insert test(id) values(id_val); end;")) { echo "stored procedure creation failed: (" . $mysqli->errno . ") " . $mysqli->error; }
does not delete procedure replace it? correct way it? point in deleting it? deleting not negate whole point of having procedure can call duration of mysql connection?
you have drop 'old' procedure first, otherwise create fail "already exists" errors. it's same pretty every object in database, e.g.
create table foo ... // creates table create table foo ... // **not** replace 1 created
you cannot 'overwrite' table/proc/db redefining it. have drop original 1 first.
consider chaos that'd occur if poor dba @ major bank accidentally ran
create database clients;
and trashed entire client db because db engine replaced original db new empty one.
Comments
Post a Comment