vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| << kj314159265358979 >> I know that one can store multiple psql commands and SQL statements in a separate "script" file, and then "source" the script file, e.g. with the \i command. My question is, can I define variables in such a script file? E.g. can I do something like the following unix-shell-like script? -- beginning of script DB=frobozz DIR=/foo/bar/baz/quux \c $frobozz \i "$DIR/other_script.sql" \i "$DIR/one_more_script.sql" \i "$DIR/yas.sql" \echo "done with $DB" -- end of script Thanks! kj314159265358979 |
| ||||
| Kynn Jones wrote: > << kj314159265358979 >> > > I know that one can store multiple psql commands and SQL statements in > a separate "script" file, and then "source" the script file, e.g. with > the \i command. > > My question is, can I define variables in such a script file? E.g. can > I do something like the following unix-shell-like script? You can use psql variables http://www.postgresql.org/docs/8.1/s...PSQL-VARIABLES Be careful with quoting issues though. -- Richard Huxton Archonet Ltd ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |