stored procedure

Prepared statements and stored procedures

Many databases support prepared statements. What are they? The prepared statement  can be thought of as a kind of compiled template for the SQL, which can be called  from an user interface and to view records.

The query only needs to be parsed (or prepared) once, but can be executed multiple times with the same or different parameters.

Below is an example of such inbuilt procedure in MySQL DB, displaying the user's previleges.



Using delimiter ( Using MySQL Work Bench Windows 8.1)

SELECT * FROM emp; $$


Prepared statements are so useful that they are the only feature that PDO will emulate for drivers that don't support them. This ensures that an application will be able to use the same data access paradigm regardless of the capabilities of the database.