runsql


NAME

runsql - executes SQL scripts standartized way


SYNOPSIS

  runsql -s psql -d $(DBNAME) -u $(DBUSER) -p $(DBPASS) file...


DESCRIPTION

This script executes native SQL shell of used database, feeding to STDIN given SQL file (or STDIN if nothing given).

It adds SQL statement to stop on error with rollback and commit on success.

It interprets some special comments translating them into native to sql commands.


SPECIAL COMMENTS

-- IGNORE ERRORS
Is replaced by sql command which cause following errors be ignored.

-- COMPLAIN ERRORS
Is replaced by SQL commands which cause script to rollback exit with non-zero exit code upon SQL errors.


BUGS

Oracle version doesn't rollback DDL statements. And everything which was executed before DDL cannot be rolled back too.


OPTIONS

-s path to sql shell
Specifies which SQL shell to use. Possible values are psql or sqlplus (optionally with full path). If not specified, attempts to find sqlplus first, and then psql on PATH.

-d database
Name of Oracle instance or Postgresql database to connect to. It is an error if this option is not specified.

-u user
Name of database user to connect as. It is an error if this option is not specified.

-p password
Database password for this user. If is not specified, password is 'prompted on /dev/tty.

16 октябрь 2007 13:45