RE: SQL::Statement parsing
- From: cougar@xxxxxxxxxxx (John Cougar)
- Date: Thu, 27 Oct 2005 10:06:40 +1000
Hiya Jeff
Thanks for the reply.
Yep and whoops, that should have read SQL::Statement.
--
I was Dumper-ing the returned $stmt from the SQL::Statement instantiation,
so got mislead by the fact that the errstr hash element appeared to remain
populated across invocations, but I did as you said, and I concur that it
appears to work fine. I got confused, it's not the first time.
IMHO, the API would be neater is it contained "parse_ok()" method - or
something similar - to provide an explicit test for successful parsing,
without having to enquire against errstr() as a (almost) side-effect.
--
WRT the "SELECT *, junk FROM x" parses successfully? question, it appears I
have been mislead for years ... I have seen uses for combining wildcards
with explicit field definitions in SELECT lists many times in the past, but
almost always on Oracle platforms.
So I re-checked my facts, and indeed, in documented definitions and railroad
diagrams, SQL parse trees do appear to allow wildcards in combo with
explicit field references. I was mislead by Oracle's brain-dead parser
always disallowing such statements (and here's me thinking that Oracle MUST
be one of the leading-edge implementations of ANSI/Standardised SQL syntax
.... appears I was mistaken - again - DOH!) ... witness:
SQL> select *, col1 from generated_router;
select *, col1 from generated_router
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
So much for completeness. I couldn't get past this, so I checked
DBI/DBD::Oracle to see if it had the same weirdness: Yep! Same ORA-00923
error, so it must be an Oracle peculiarity.
--
On the other hand, why do you (as, indeed, does PostgreSQL) enforce the use
of the 'AS' keyword in column aliasing? Just a question, AS is optional in
SQL'92.
--
The doco issue was NOT a criticism, only an observation, and I will
contributed patches as requested ... chat to you offline about this, dude!
Thanks heaps for your efforts, Jeff. Keep up the great work.
Regards,
John.
PS> On the Structure.pod, it says users should instantiate a parser and pass
the instance variable into the Statement constructor as an argument. In your
reply, you just created Statement->new($sql). I know that this works, but
what is the default dialect?
I can tell that it's not ANSI ;-) ... happy to expand on this if needs be!
_______
+------------------ ////////------+----------------------------+
| John V Cougar __/ / | Voice: +61 2 6208 1683 |
| System Engineer / / /\ DBA +----------------------------+
| Telstra Internet \/_/ \ Devel | E-Mail: cougar@xxxxxxxxxxx |
+-------------------\____/ -------+----------------------------+
.
- Follow-Ups:
- Re: SQL::Statement parsing
- From: Jeff Zucker
- Re: SQL::Statement parsing
- References:
- Re: DBI::Statement parsing
- From: Jeff Zucker
- Re: DBI::Statement parsing
- Prev by Date: RE: Newline inserted?
- Next by Date: Re: SQL::Statement parsing
- Previous by thread: Re: DBI::Statement parsing
- Next by thread: Re: SQL::Statement parsing
- Index(es):