Michael Hirmke wrote:

Hi *,

I have a few questions regarding SQL::Statement:

The first one probably can only be answered by the quthor himself

That's me.

: Will
SQL::Statement be able to understand the "ALTER" command in the
future

Yes but not any time soon unless someone wants to collaborate on it or send patches.

or do I have to implement it myself? I tried to activate it with
 $sql_parser->feature( 'valid_commands', 'ALTER', 1 );
but that obviously isn't enough.
It's not too hard to add support for that to the parser but it's a bit more involved than what you show.

What about statements as "FOREIGN KEY" and "PRIMARY KEY" (see below)?
At the moment SQL::Statement is much better at DML than it is at DDL. Primary key is recognized as a column definition e.g. "pid INT PRIMARY KEY" but not as a table defnition e.g. "PRIMARY KEY (col1,col2)".

The second one: I have a file containing several SQL statements mainly
for creating and altering tables. This file is created by a case tool
for database design

[...]

I have to parse this file, check the syntax of the statements and then
transform them to something, which is completely different from SQL.
Is SQL::Statement the appropraite module for this or is there a module
that could do this job in a better way?
In general, SQL::Statement is meant to work that way. But given the fact that you are dealing mostly with DDL and that's SQL::Statement's weakest point, I recommend you look at SQL::Translator which has very robust DDL handling (but little or no DML handling). If you have both complex DDL and DML you may need to use both modules.

One more question: Is there any way to access the "column_defs" hashes
via object methods or do I have to read the structure directly (which
is deprecated as stated in the man page).
Again, because DDL is currently weak, I have not yet created a method to access the column definitions in a CREATE statement, so you do need to use the hash structure directly. Using the hash is deprecated because eventually everything will be accessed by methods, not because there are problems with the way it works now.

Good luck!

--
Jeff

Reply via email to