What happens if a prepared statement named countryByID already exists when the above statement is executed?

The city table has the following structure:

Consider the statement with an incorrect field name:
PREPARE countryBYID FROM ‘SELECT country FROM city WHERE ID=?,
What happens if a prepared statement named countryByID already exists when the above
statement is executed?

The city table has the following structure:

Consider the statement with an incorrect field name:
PREPARE countryBYID FROM ‘SELECT country FROM city WHERE ID=?,
What happens if a prepared statement named countryByID already exists when the above
statement is executed?

A.
A duplicate name error will result because a prepared statement with the same name
already exists.

B.
An unknown column error will result and the old prepared statement definition will remain
in effect.

C.
An unknown column error will result and no prepared statement named countryByID will
exist.

D.
A warning will result and the old prepared statement definition will remain in effect.



Leave a Reply 4

Your email address will not be published. Required fields are marked *


leo

leo

Correct answer is not A but C!!! Take care

zz

zz

C

I have tested it.

Roy

Roy

C
If a prepared statement with the given name already exists, it is deallocated implicitly before the new statement is prepared. This means that if the new statement contains an error and cannot be prepared, an error is returned and no statement with the given name exists.
http://dev.mysql.com/doc/refman/5.7/en/prepare.html

armir01

armir01

C surely.
PREPARE countryBYIDs FROM ‘SELECT names FROM city’;
execute countryByIDs;