Subject Re: [firebird-support] What is more effective execute block or select?
Author Helen Borrie
Re: [firebird-support] What is more effective execute block or select? Set wrote:

I just wonder if you've thought EXECUTE STATEMENT where you've written

Friday, January 29, 2016, 6:55:09 AM, Ann Harrison wrote:

Probably.  Does EXECUTE BLOCK allow you to build up the block at runtime?
If so, then I think I may be right unless the compiler is clever enough to recognize
that your particular block is static.


If EXECUTE BLOCK requires static queries, then I'm completely wrong.  If not, you might be better writing procedures for updates like this, or as Mark suggests, MERGE.

Easy to confuse them, in the heat of the email moment!  

EXECUTE STATEMENT is the one that is used in PSQL to build up the statement
during execution of the module.  It's not directly available in DSQL.

EXECUTE BLOCK is a DML statement that allows you to construct a module of
non-persistent PSQL code that executes on the fly.  It's not available for
direct use inside a persistent PSQL module (trigger, stored proc, stored function).

"Indirect use" is possible both ways.  One can use EXECUTE STATEMENT inside a
complicated EXECUTE BLOCK block and EXECUTE BLOCK inside a complicated EXECUTE STATEMENT
statement.  But why would you want to?  Sheesh.

The usual size limits apply, of course.