D Medved > TSQL-SplitStatement > TSQL::SplitStatement

Download:
TSQL-SplitStatement-0.14.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.14   Source  

NAME ^

TSQL::SplitStatement - Implements similar functionality to SQL::SplitStatement, but for TSQL.

VERSION ^

Version 0.14

SYNOPSIS ^

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.

DESCRIPTION ^

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.

DEPENDENCIES ^

TSQL::SplitStatement depends on the following modules:

AUTHOR ^

Ded MedVed, <dedmedved at cpan.org>

BUGS ^

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.

METHODS ^

new

It creates and returns a new TSQL::SplitStatement object.

splitSQL

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

This is the method which builds the regular expression that recognises the start of a TSQL statement. Internal only.

LIMITATIONS ^

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.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc TSQL::SplitStatement

You can also look for information at:

ACKNOWLEDGEMENTS ^

None yet.

SEE ALSO ^

LICENSE AND COPYRIGHT ^

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.

syntax highlighting: