Groups > Interbase > Interbase General discussion > EBNF definition for syntax of Column Alias




Re: EBNF definition for syntax of Column Alias

Re: EBNF definition for syntax of Column Alias
17 Apr 2008 09:19:45 -0700
Enquiring Mind wrote:

> I find it surprising that a SQL database coming from a company that
> supplies a Pascal compiler does not publish a proper and complete
> EBNF definition of its SQL syntax (at least in the version 6.5 that I
> am using). 

	I'm not sure why, since there's no BNF for the compiler or the Delphi
language, either. :)

> Consider the following example (SQL Dialect 3):
> 
> select P.ProjectIndex  as Number, P.Name as Project, C.Name as Client
> from Projects P inner join Clients C
> on P.ClientIndex= C.ClientIndex
> order by P.ProjectIndex
> 
> If I enclose the aliases Number, Project, and Client in double quotes
> to get them returned in a case-sensitive way, an error is thrown.

	Are you using client dialect 3?

> Also if instead of the string "Number" I use "Index" as
an alias, an
> error is thrown, presumably because it clashes with a reserved word.

	No, reserved words are allowed in delimiters. (In dialect 3.)

> But given that its scope is limited by the use of the word
"as",why
> is it being compared to a reserved word?

	Well, reserved words are *always* reserved -- except inside
delimiters.

-- 
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
  Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
How to ask questions the smart way:
Post Reply
EBNF definition for syntax of Column Alias
Thu, 17 Apr 2008 17:03:27 +010
Hi,

I find it surprising that a SQL database coming from a company that supplies 
a Pascal compiler does not publish a proper and complete EBNF definition of 
its SQL syntax (at least in the version 6.5 that I am using). The SQL 
reference document gives syntax definitions that superficially resemble 
EBNF, but do not drill down to the definition of final entities. Anyone that 
knows the original Pascal language report by Wirth et al. will remember the 
simplicity, power and elegance of the EBNF definition of the language. The 
whole of the Pascal language was completely and unambiguous defined by a 
couple of pages of EBNF syntax. By contrast the much longer Interbase SQL 
Reference file fails to do the same for the SQL dialect that it is supposed 
to be defining.

For example, I was interested to find out the syntax for column aliases. A 
book on SQL I consulted  mentions that many versions of SQL permit the use 
of blanks and mixed case strings in an alias if the alias is enclosed in 
double quotes. However when I try using either single or double quotes for 
this purpose, Interbase throws an error. I therefore looked up the 
definition of the column alias syntax in the SQL Reference file that is 
shipped with the software. Although the alias is included as an entity in 
the syntax definition of the SELECT statement, nowhere is the syntax for 
this entity actually defined. I found a similar problem with the definition 
of the GROUP BY clause.

Consider the following example (SQL Dialect 3):

select P.ProjectIndex  as Number, P.Name as Project, C.Name as Client
from Projects P inner join Clients C
on P.ClientIndex= C.ClientIndex
order by P.ProjectIndex

If I enclose the aliases Number, Project, and Client in double quotes to get 
them returned in a case-sensitive way, an error is thrown. Also if instead 
of the string "Number" I use "Index" as an alias, an error
is thrown, 
presumably because it clashes with a reserved word. But given that its scope 
is limited by the use of the word "as",why is it being compared to a 
reserved word?

I am sure I must be unaware of some very simple facts about the Interbase 
SQL dialect. Can anyone help?

TIA,

EM

Post Reply
about | contact