SQL::Bibliosoph::CatalogFile - Bibliosoph SQL Statements Parser


SQL-Bibliosoph documentation  | view source Contained in the SQL-Bibliosoph distribution.

Index


NAME

Top

SQL::Bibliosoph::CatalogFile - Bibliosoph SQL Statements Parser

VERSION

Top

2.0

DESCRIPTION

Top

Reads a SQL library statements file, using the BB format (SEE below)

BB Format

Top

--[ Query_name1 ] SQL statement

The query name must be a simple string, case sensitive, with no spaces. The file can have comment in every line, starting with #. Statements can include bind params denoted with question mark `?`. Optionally, parameters can be numbered: 1?, 2?, 3? ... This allows to reuse paraments, like in:

		SELECT * 
			FROM user
			 WHERE name = 1? OR nick = 1?

The bind parameter number can be preceded by a `#`. This force the parameter to be strictly numeric. This is useful for using bind parameters with the LIMIT clause.

Examples

A simple query, using two bind parament
	--[ GET_T1 ]
	# A very nice commentA
		SELECT		t1.*
		FROM		table1 t1
	# A other comment
        LEFT JOIN   table2 t2
        ON			t1.id = t2.t1_fk
        WHERE		t2.id = ? 
		LIMIT #?

An insert statement. This returns the last inserted ID.
	--[ INSERT_USER ]
	# This returns LAST_INSERT_ID if `user` has a auto_increment column
		INSERT 
			INTO user (name,country) 
			VALUES 
			(?, IFNULL(?,'US') )

An update statement. Returns modifed rows.
	--[ AGE_USERS ]
	# This returns the modified rows
		UPDATE user
			SET age = age + 1
			WHERE birthday = ? 

The select using numeric and ordered params
	--[ GET_USERS ]
	# Example using numeric and ordered params
		SELECT * 
			FROM user 
			WHERE 
				(1? IS NULL OR country = 1? )
				AND (2? IS NULL OR state =  2?)
			LIMIT #3?,#4?

AUTHORS

Top

SQL::Bibliosoph by Matias Alejo Garcia (matiu at cpan.org) and Lucas Lain (lucas at confronte.com).

COPYRIGHT

Top

SUPPORT / WARRANTY

Top

The SQL::Bibliosoph is free Open Source software. IT COMES WITHOUT WARRANTY OF ANY KIND.

SEE ALSO

Top

	SQL::Bibliosoph
	SQL::Bibliosoph::CatalogFile

At http://nits.com.ar/bibliosoph you can find: * Examples * VIM syntax highlighting definitions for bb files * CTAGS examples for indexing bb files.

ACKNOWLEDGEMENTS

Top

To Confronte.com and its associates to support the development of this module.


SQL-Bibliosoph documentation  | view source Contained in the SQL-Bibliosoph distribution.