The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Template::Plugin::JavaSQL - Help generate Java from database schemas.

SYNOPSES

Within an XML file processed by the Java plugin:

        <sql:
                query="select foo as f, bar as b from some_table"
        >

        or

        <sql:
                table="some_table"
        >

Via a template such as:

        [% USE Java %]
        [% Use JavaSQL %]
        ...
                mySelect        = myConnection.prepareStatement("
        select [% JavaSQL.columnNames.join(", ") %]
        from [% JavaSQL.tables.join(", ") %]
        [% IF JavaSQL.where %]
        where [% JavaSQL.where %]
        [% END %]
        [% IF JavaSQL.order %]
        order by [% JavaSQL.order %]
        [% END %]
        ");

DESCRIPTION

In addition to methods that refer to parts of a SQL query, any columns resultant from the query or table will be added as java variables to the variables hash, with close-as-possible mapped types.

METHODS

new

Constructor. If given one parameter of type Template::Context, will use that as a context. Then process the contents of "sql:" within the stash. This is what typically happens inside a template when a [% USE JavaSQL %] directive is encountered.

query

The complete query, either supplied at instantiation or inferred from other arguments.

where

The "where" portion of the SQL query, excluding the word "where" itself.

tables

A list of tables used by the query.

order

An ORDER BY clause, if one was used.

columnNames

A list of column names used in the query.

columns

Intended to be used as [% FOREACH JavaSQL.columns %] ... See "SYNOPSYS".

parseQuery

Used internally to parse a SQL query and set the appropriate state variables.

ENVIRONMENT

DBI_DSN

DBI Data Source Name, for example, the data source for MySQL and database name "test" it would be: dbi:mysql:database=test

DBI_USER

User name to connect to the database as.

DBI_PASS

Password for database, can be blank for no password.

AUTHOR

Rafael Kitover (caelum@debian.org)

COPYRIGHT

This program is Copyright (c) 2000 by Rafael Kitover. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

BUGS

Probably many.

TODO

A very great deal.

SEE ALSO

perl(1), Template(3), Template::Plugin::Java::Utils(3), Template::Plugin::Java::Constants(3),