sqlldr LRM-00112: multiple values not allowed for parameter 'control' - oracle

I have a shell script with this code:
sqlldr $ws_usr_eva/$ws_pass_eva#$ws_esq_eva CONTROL=/$HOME/controlfiles/CONTROL_FILE.CTL LOG=/$HOME/batch/log/LOG_FILE.$fecfile.log DATA=/$HOME/batch/input/INPUT_FILE_$fecfile.txt > /$HOME/batch/log/result_loader_eva.ora
The variables $ws_usr_eva, $ws_pass_eva and $ws_esq_eva are filled before I execute the sqlldr. I already check the content and its ok.
So when I run the script, it show me: LRM-00112: multiple values not allowed for parameter 'control'
I tried to run the script without the variables, and it works fine:
sqlldr user/pwd#schema CONTROL=/$HOME/controlfiles/CONTROL_FILE.CTL LOG=/$HOME/batch/log/LOG_FILE.$fecfile.log DATA=/$HOME/batch/input/INPUT_FILE_$fecfile.txt > /$HOME/batch/log/result_loader_eva.ora
I have to use variables in the sqlldr, because it reads them from a configuration file.
I also try with sqlldr userid=$ws_usr_eva/$ws_pass_eva#$ws_esq_eva ... but it didn't work.
Can you help me?
Thanks in advance.

Incase it helps anybody, you need to enclose your paths (data, control, log) in single qoutes. Double qoutes will not work (although sqlldr will not complain, but rather simply ignore the double qoutes).

In your shell, try to escape your variables::
sqlldr "${ws_usr_eva}/${ws_pass_eva}#${ws_esq_eva}" "CONTROL=${HOME}/controlfiles/CONTROL_FILE.CTL" "LOG=${HOME}/batch/log/LOG_FILE.${fecfile}.log" "DATA=${HOME}/batch/input/INPUT_FILE_${fecfile}.txt" > "${HOME}/batch/log/result_loader_eva.ora"

Related

How can I update column values with the content of a file without interpreting it?

I need to update values in a column when the row matches a certain WHERE clause, using the content of a text file.
The content of the file is javascript code and as such it may contain single quotes, double quotes, slashes and backslashes - out of the top of my mind, it could contain other special characters.
The content of the file cannot be modified.
This has to be done via psql, since the update is automated using bash scripts.
Using the following command - where scriptName is a previously declared bash variable -
psql -U postgres db<<EOF
\set script $(cat $scriptName.js))
UPDATE table SET scriptColumn=:script WHERE nameColumn='$scriptName';
EOF
returns the following error
ERROR: syntax error at or near "{"
LINE 1: ...{//...
^
I would like to treat the content of the file $scriptName.js as plain text, and avoid any interpretation of it.
You should quote the variable:
UPDATE table SET scriptColumn=:'script' WHERE ...
That causes the contents of the variable to be properly escaped as a string literal.
I found a solution to my problem, even though I don't know why it works.
I leave it here in the hope it might be useful to someone else, or that someone more knowledgeable than me will be able to explain why it works now.
In short, setting the variable as a psql parameter did the trick:
psql -U postgres db -v script="$(cat $scriptName.js)"<<EOF
UPDATE table SET scriptColumn=:'script' WHERE nameColumn='$scriptName'
EOF
Not sure how this differs from
psql -U postgres db <<EOF
\set script "$(cat $scriptName.js)"
UPDATE table SET scriptColumn=:'script' WHERE nameColumn='$scriptName'
EOF
which I tried previously and returns the following error:
unterminated quoted string
ERROR: syntax error at or near "//"
LINE 1: // dummy text blahblah
Thanks to everybody who helped!

Execute sqlplus command in perl

I am trying to check sql connection via sqlplus command in perl.
I have used the following code to do this.
print "Befores\n";
$rc=system("sqlplus system/system #sqlfile.sql");
print "After $rc\n";
sleep(10);
The returnes value in rc is 0 this time. But when I give wrong credentials like. The sqlfile.sql file contains the only sql command 'EXIT'.
$rc=system("sqlplus systemabc/system #sqlfile.sql");
This also ends with the return code 0. But, manually doing the Credentials are wrong.
Help me out in solving this...
Thanks in advance. :)
Yes dear friens,,,
It's working fine now.
I just added '\' before #sqlfile.sql, i.e, I escaped the '#' symbol and I mentioned the database name after my password. Now I am getting the perfect output. :)
The change is as bellow:
$rc=system("sqlplus -L system/system#tstdb1 \#sqlfile.sql");
Here the format I used is:
sqlplus -L Uname/Password#DBName \#SqlFileContainingMySQLQuries
And -L Specifies not to reprompt for username or password if the initial connection does not succeed. For more info goto About SQLPLUS
I also tried without escaping the '#' symbol before sqlfile.sql, But the change also should apply for inverted comas, I used Single inverted comas instead of double inverted comas as bellow as mentioned by #René Nyffenegger :
$rc=system('sqlplus -L system/system#tstdb1 #sqlfile.sql');
Here the format I used is:
sqlplus Uname/Password#DBName #SqlFileContainingMySQLQuries
This also works fine.
Yeah... :) I too tried this, Thanks for the answer #user252025
I was doing:
$rc=system("sqlplus -L user/user \#sql_file.sql");
Da rtrn code was wrong for me
Now I ve changed to
$rc=system("sqlplus -L user/user#Mydb \#sql_file.sql");
Its working fine..
Thanks again...
The problem is the line
$rc=system("sqlplus system/system #sqlfile.sql");
You have a string quoted with double quotes ("..."). Such strings try to epxand variables (starting with #, $ and %). Since you have #sqlfile in the string, perl assumes this to be an array (which, of course it is not).
Remedy:
$rc=system('sqlplus system/system #sqlfile.sql');
Why are you doing this? DBI exists to provivide a sane and secure way of using databases and sensibly getting the output/return/errors from them.

Some symbols don't effect cmd commands while others do

I noticed that cmd seems to accept some characters at the ends of commands. for example all of the following function correctly:
cls.
cls;
cls(
cls\
cls+
cls=
cls\"whatever"
cls\$
cls\#
and these do not:
cls'
cls$
cls)
cls-
cls#
cls\/
Does anybody know why this happens?
Thanks in advance.
It depends on the batch parser.
;,= are general batch delimiters, so you can append/prepend them to the most commands without effect.
;,,= ,=; echo hello
;,cls,;,,
The . dot can be appended to the most commands, as the parser will try to find a file named cls (without extension) cls.exe cls.bat, and when nothing is found then it takes the internal command.
The opening bracket is also a special charcter that the parser removes without error.
The \ backslash is used as path delimiter, so sometimes it works but sometimes you could change even the command.
cls\..\..\..\windows\system32\calc.exe

Export data from mathematica script

I am writing a mathematica script and running it in the linux batch shell. The script gives as a result a list of numbers. I would like to write this list to a file as a one single column without the braces and commas. For this, I tried to use Export comand as
Export["file.txt", A1, "Table"]
but I get the error:
Export::infer: Cannot infer format of file test1.txt
I tried with other format but i got the same error.
Could someone please tell what is wrong and what i can do? Thank beforehand
From what I understand you are trying to export the file in TABLE, why don't you try something like this ,
Export["file.txt", A1, "Text"]
This:
A1 = {1,2,3};
Export["test.tab", Transpose[{A1}], "Table"];
produces a single column without braces and commas.

Shell Scripting: Using a variable to define a path

My problem lies with my confusion with shell variables.
To my understanding, variables allow me to store a value (String in this case) and to call it later in my code. So if I wanted to have a variable that holds the path to some set of scripts, I could ideally just store it like this:
SPTH = '/home/Foo/Documents/Programs/ShellScripts/Butler'
//Later on in the script//
cd $SPTH
./script1
What I'm trying to do, with probably the wrong syntax, is to set the path to variable SPTH.
Then I use cd with argument $SPTH.
Ideally this would allow me to run the file there without typing in the path. However it doesn't work. The $SPTH is ignored and the result is as if cd was used alone.
So what am I doing wrong? And what would be a way to do this?
Don't use spaces...
(Incorrect)
SPTH = '/home/Foo/Documents/Programs/ShellScripts/Butler'
(Correct)
SPTH='/home/Foo/Documents/Programs/ShellScripts/Butler'
To add to the above correct answer :-
For my case in shell, this code worked (working on sqoop)
ROOT_PATH="path/to/the/folder"
--options-file $ROOT_PATH/query.txt

Resources