Subject Re: [firebird-support] is sql interpreted language?
Author Helen Borrie
At 12:26 PM 29/10/2004 +0000, you wrote:

>I have been told is sql an interpreted language?

Broadly speaking, it could be seen that way, but it's really quite
different to an interpreted language like Java or VB. It's meant to be a
standard language interface for applications that is totally consistent,
regardless of what each different vendor's implementation does with it when
it a request arrives at the server.

>Is this the case and if so does this mean that the sql script is read
>every time it is applied to a record?

SQL requests are formulated as statements. What the the server deals with
is one statement. Client interfaces are available that can pass a number
of statements to the server, which the server will process one at a time,
in arrival sequence. Statements handled in this fashion are read from text
files, which are known as scripts. The server doesn't know anything about
scripts.


>or
>
>Does it mean that the sql script is read in once and converted to a
>"pcode" (like vb used to be) format and then applied to all records
>specified?

Forget scripts...SQL statements are just "containers" that specify,
according to pre-defined conventions, what is to be extracted or targeted
and how and in what way. The server is a kind of super-program that
processes requests by passing various function calls and structures around
several subsystems. So, although there are points during the process where
pieces of the SQL statement logic are converted into a compact binary
format, there's not really any kind of "pcode equivalent", since SQL isn't
a programming language.

The exception is stored procedures. These are modules of procedural code
that use some programming constructs not available in client SQL
requests. They can (and usually do) include regular SQL requests as
well. They are defined in a special type of definition statement and are
stored on the server, precompiled and ready to be called by clients or by
other procedures.

>Can the sql scripts in FB be "compiled" for either better performance
>or improved security?

Stored procedures are compiled and, in fact, can't be used unless they
are. You can use SPs to perform operations and extractions that would be
impossible, or slow, using the regular SQL statement syntaxes. Firebird
also has triggers, another form of procedural module, that are bound to
tables and will run automatically when the table changes its state. They
are also precompiled.

hth
./heLen