parallel
[Top][All Lists]
Advanced

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

Re: How to do multiple commands as command line arguments for GNU sql


From: Hans Schou
Subject: Re: How to do multiple commands as command line arguments for GNU sql
Date: Mon, 20 Sep 2010 20:24:52 +0200 (CEST)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

On Tue, 14 Sep 2010, Ole Tange wrote:

If you want to use GNU sql for running multiple commands on Oracle you
will have to do something like:

sql oracle://hr:hr@/xe  "SELECT 1 FROM DUAL;
SELECT 2 FROM DUAL;"

I do not like the part that you have to put a newline on the command
line. You can of course do:

(echo "SELECT 1 FROM DUAL;"; echo "SELECT 2 FROM DUAL;") | sql
oracle://hr:hr@/xe

but I really would like to make it possible to give the SQL queries as
arguments. So I am thinking about this:

 sql oracle://hr:hr@/xe "SELECT 1 FROM DUAL;" "SELECT 2 FROM DUAL;"
 sql oracle://hr:hr@/xe "WHENEVER SQLERROR EXIT FAILURE" "SELECT 1
FROM DUAL;" "SELECT 2 FROM DUAL;"

i.e. each argument will get a newline added before being passed along
to sqlplus. I have implemented this in the current git version.

An alternative:

 sql oracle://hr:hr@/xe "SELECT 1 FROM DUAL;\nSELECT 2 FROM DUAL;"
 sql oracle://hr:hr@/xe "WHENEVER SQLERROR EXIT FAILURE\nSELECT 1
FROM DUAL;\nSELECT 2 FROM DUAL;"

Where '\n' will be substituted with a newline. Personally I find the
first version easier to read.

Another alternative:

 sql oracle://hr:hr@/xe "SELECT 1 FROM DUAL;%0aSELECT 2 FROM DUAL;"
 sql oracle://hr:hr@/xe "WHENEVER SQLERROR EXIT FAILURE%0aSELECT 1
FROM DUAL;%0aSELECT 2 FROM DUAL;"

Where '\n' will be substituted with a newline. Personally I find the
first version easier to read. Also % is being used in LIKE.

Which one do you like better? Do you have other ideas?

I would prefer backslash-encoding '\n' in the parameteres. And '\x0a' can also be a newline.

If a special character is required in the dburi part I would prefer percent encoding.

/hans
--
Horsebakken 78, DK-2400 København NV

reply via email to

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