Guys - Simple code, i am trying to get a number back from sqlplus call to a query. After that, i need to use that number in a loop.
---------------------------------
#!/bin/ksh
VALUE=`sqlplus -silent sh/password@sh <<END
set pagesize 0 feedback off verify off heading off echo off
select max(sequence#) from v\\\$log_history;
exit;
END`
$VALUE=$VALUE + 1
---------------------------------
Problem is, as soon as i use the variable returned from the sqlplus call, it gives me the following error:
bash: $'184\r=': command not found
I have gone through any number of code syntax and i still need help getting this \r guy out of the variable into a new one so i can do some operations on it.
Any help is "GREATLY" appreciated
---------- Post updated at 04:51 AM ---------- Previous update was at 04:35 AM ----------
I am guessing this problem will not be resolved if i spool the output to a file and read it back in?
#!/bin/ksh
VALUE=`sqlplus -silent "/ as sysdba" <<END
set pagesize 0 feedback off verify off heading off echo off
select max(sequence#) from v\\\$log_history;
exit;
END`
VALUE=$VALUE + 1
Replace
$VALUE=$VALUE + 1
with
VALUE=$VALUE + 1
to increment archive log number.
Without the backticks we need one backslash.
Within the backticks we can use two or three backslashes.
Please check the example below
$ VALUE=`sqlplus -S "/ as sysdba" <<END
set pagesize 0 feedback off verify off heading off echo off
select max(sequence#) from v\\$log_history;
exit;
END`
$ echo $VALUE
1216
$ VALUE1=`sqlplus -S "/ as sysdba" <<END
set pagesize 0 feedback off verify off heading off echo off
select max(sequence#) from v\\\$log_history;
exit;
END`
$ echo $VALUE1
1216
Both are working
I use(required) three \\\ at one suituation to connect oracle !!!!! Sorry I forgot the suituation
Interesting scenario scripter.online. I have been writing unix shell scripts to run Oracle processes for too many years and long ago stopped using unix "here documents" for Oracle programs because of the clashes with unix shell. I can explain the multiple backslash scenario, but continue to recommend storing Oracle programs in ".sql" text files.
BTW: The link provided leads to a website with many typos. View with caution.
P.S. forget to "quit" an Oracle session.