Re: creating view with user variable

From: Axel Schwenke <axel.schwenke_at_gmx.de>
Date: Fri, 27 Jan 2017 10:57:44 +0100
Message-ID: <o6f5fi$g6b$1_at_dont-email.me>


[Quoted] On 26.01.2017 21:48, Jerry Stuckle wrote:
> Yes, you can use a prepared statement for that. Much less efficient,
> though and I tend to stay away from it.

[Quoted] Dynamic SQL is no less (or more) efficient than generating the SQL on the client and sending it as static string to MySQL. In the end it takes the same way through SQL parser and executer. The PREPARE + EXECUTE steps are just necessary to emulate the missing EXECUTE IMMEDIATE functionality.

There are other tasks, where dynamic SQL is very handy and elegant, i.e. when it comes to using results from INFORMATION_SCHEMA to build maintenance queries. Imagine a procedure that finds all tables in the `foo` database using the MyISAM engine and running OPTIMIZE TABLE on them.

XL Received on Fri Jan 27 2017 - 10:57:44 CET

Original text of this message