mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-12-22 20:57:53 +00:00
sql: Each arg on command line will add a \n. Useful for Oracle
This commit is contained in:
parent
ceca2fea75
commit
28f9796b4e
|
@ -10,6 +10,9 @@ sql :pg_foo?'\dt %0a SELECT * FROM users'
|
|||
|
||||
cat ~/.sql/aliases | parallel --colsep '\s' sql {1} '"select 0.14159+3;" | grep -q 3.14159 || (echo dead: {1}; exit 1)'
|
||||
|
||||
--list-tables
|
||||
select OBJECT_NAME from user_objects where object_type = 'TABLE';
|
||||
|
||||
== FEX ==
|
||||
|
||||
fex syntax for splitting fields
|
||||
|
|
6
src/sql
6
src/sql
|
@ -406,7 +406,7 @@ my $queryfile = "";
|
|||
if($dburl{'query'}) {
|
||||
my $fh;
|
||||
($fh,$queryfile) = tempfile(SUFFIX => ".sql");
|
||||
print $fh $dburl{'query'};
|
||||
print $fh $dburl{'query'},"\n";
|
||||
close $fh;
|
||||
$batch_command = "cat $queryfile - | $batch_command";
|
||||
}
|
||||
|
@ -415,7 +415,9 @@ do {
|
|||
if(@ARGV) {
|
||||
$::opt_debug and print "$batch_command\n";
|
||||
open(M,"| $batch_command") || die("mysql/psql/sqlplus not in path");
|
||||
print M "@ARGV";
|
||||
for(@ARGV) {
|
||||
print M "$_\n";
|
||||
}
|
||||
close M;
|
||||
} elsif (is_stdin_terminal()) {
|
||||
$::opt_debug and print "$interactive_command\n";
|
||||
|
|
|
@ -50,3 +50,7 @@ stdout sql ''
|
|||
echo "### Test dburl :"
|
||||
stdout sql ':'
|
||||
|
||||
echo "### Test oracle with multiple arguments on the command line"
|
||||
echo ":oraunittest oracle://hr:hr@/xe" >> ~/.sql/aliases
|
||||
perl -i -ne '$seen{$_}++ || print' ~/.sql/aliases
|
||||
sql :oraunittest "WHENEVER SQLERROR EXIT FAILURE" "SELECT 'arg2' FROM DUAL;" "SELECT 'arg3' FROM DUAL;"
|
||||
|
|
|
@ -19,16 +19,19 @@ It works
|
|||
### Test alias followed by SQL as arg
|
||||
Test statement in alias
|
||||
It works
|
||||
'Arg on cmdline'
|
||||
Arg on cmdline
|
||||
### Test alias with query followed by SQL as arg
|
||||
Test statement in alias
|
||||
It works
|
||||
Query added to alias
|
||||
'Arg on cmdline'
|
||||
Arg on cmdline
|
||||
### Test alias with statement .sql/aliases
|
||||
Test statement in alias
|
||||
It works
|
||||
Query added to alias
|
||||
'Query from stdin'
|
||||
Query from stdin
|
||||
Test statement in alias
|
||||
It works
|
||||
|
@ -46,3 +49,14 @@ Error:
|
|||
: is not defined in /home/tange/.sql/aliases /home/tange/.dburl.aliases /etc/sql/aliases /usr/local/bin/dburl.aliases /usr/local/bin/dburl.aliases.dist
|
||||
|
||||
sql [-hnr] [--table-size] [--db-size] [-p pass-through] [-s string] dburl [command]
|
||||
### Test oracle with multiple arguments on the command line
|
||||
|
||||
'ARG2'
|
||||
------------
|
||||
arg2
|
||||
|
||||
|
||||
'ARG3'
|
||||
------------
|
||||
arg3
|
||||
|
||||
|
|
Loading…
Reference in a new issue