TSQL::SplitStatement - Implements similar functionality to SQL::SplitStatement, but for TSQL.
Version 0.15
This is a simple module which tries to split TSQL code into simple, recognisable code elements. It implements similar functionality to SQL::SplitStatement, but does so for TSQL. TSQL notoriously doesn't bother with statement separators or teminators. There is no overlap with or dependency on SQL::SplitStatement. But being lazy, I've loosely based the documentation on that for SQL::SplitStatement.
The module splits TSQL code into recognisable units..
It removes comments, distinguishes strings and quoted names from code, and then returns a list of TSQL statements and/or 'tokens'.
It splits the code by attempting to recognise the start of the statement following the current one. It uses a mix of Regular Expressions and Parse::RecDescent.
It's purely an adhoc, heuristic approach, and was written to suit my own immediate requirements. The futher reaches of TSQL, including the less commonly used DDL statements are not covered. There is some attempt to cover elements of TSQL introduced in SQL Server 2008, but there is nothing to cover SQL Server 2012. It is a work in progress. Bug reports are welcomed, but may not necessarily be acted upon. Contributors are more than welcome.
TSQL::SplitStatement depends on the following modules:
List::Util
List::MoreUtils
Clone
autodie
Ded MedVed, <dedmedved at cpan.org>
<dedmedved at cpan.org>
Please report any bugs or feature requests to bug-tsql-splitstatment at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=TSQL::SplitStatement. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-tsql-splitstatment at rt.cpan.org
new
TSQL::SplitStatement->new()
It creates and returns a new TSQL::SplitStatement object.
splitSQL
$sql_splitter->splitSQL( $sql_string )
This is the method which actually splits the SQL code into its atomic components.
It returns a list containing the atomic statements, in the same order they appear in the original SQL code.
my $sql_splitter = TSQL::SplitStatement->new(); my @statements = $sql_splitter->splitSQL( 'SELECT 1;SELECT 2; ); print 'The SQL code contains ' . scalar(@statements) . ' statements.'; # The SQL code contains 2 statements.
tokeniser
TSQL::SplitStatement->tokeniser()
This is the method which builds the regular expression that recognises the start of a TSQL statement. Internal only.
No limitations are currently known, as far as the intended usage is concerned. You *are* bound to uncover a large number of problems. The handling of create procedure/trigger/function statements is problematic.
Please report any problematic cases.
You can find documentation for this module with the perldoc command.
perldoc TSQL::SplitStatement
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=TSQL::SplitStatement
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/TSQL::SplitStatement
CPAN Ratings
http://cpanratings.perl.org/d/TSQL::SplitStatement
Search CPAN
http://search.cpan.org/dist/TSQL::SplitStatement/
None yet.
SQL::SplitStatement
Copyright 2012 Ded MedVed.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install TSQL::SplitStatement, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TSQL::SplitStatement
CPAN shell
perl -MCPAN -e shell install TSQL::SplitStatement
For more information on module installation, please visit the detailed CPAN module installation guide.