[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sql: with argument substitution

From: Ole Tange
Subject: sql: with argument substitution
Date: Thu, 14 Apr 2011 00:28:34 +0200

At my presentation yesterday a person in the audience suggested being
able to make arguments when making an sql-script executable.

So something like:

  #!/usr/bin/sql -Y {2}

  SELECT * FROM mytable WHERE user = '{1}';

You could then call that script like:

  ./myscript joe mysql:///


  {1} would then be replaced with joe
  {2} would then be replaced with mysql:///

I am not sure if the {1} syntax is good or if the syntax should use $1
instead. I would prefer using a syntax that is easy to understand -
preferably something already known and which does not make problems
with any dialect of SQL. So if some obscure SQL dialect uses $1 for
something else (e.g. in functions), then that is a no-go.

So dear users: Please give some advice on what you think about this
and if you can find an even better idea for implementation.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]