Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

-1 votes
1 answers
1882 views
Generating .XLS file as an output file of sqlplus query and sending that .XLS file as an attachment in email
I am generating output file (.xls format) from the below DB query- sqlplus -S -L user/pass@DB > home/test/query_output.xls set line 22000 set head off set feedback off SELECT * from table; EOF The `query_output.xls` file contains records as below- VIM 00 34562356 22412299 Dated 11-JUN-18 OMM sansra...
I am generating output file (.xls format) from the below DB query- sqlplus -S -L user/pass@DB > home/test/query_output.xls set line 22000 set head off set feedback off SELECT * from table; EOF The query_output.xls file contains records as below- VIM 00 34562356 22412299 Dated 11-JUN-18 OMM sansra carla Yes No No No 02356478 14-SEP-18 To send this query_output.xls file as an attachment in email, I am using below- uuencode home/test/ query_output.xls | mailx -s "Subject" me@Domain.com Also tried uuencode query_output.xls query_output.xls | mailx -s "Subject" me@Domain.com But not getting the data in attachment received in email. Also tried mailx -a and mutt but its showing 'illegal option -- a' and 'command not found' resp. mailx -a home/test/query_output.xls -s "Subject" me@Domain.com < /dev/null mutt -a query_output.xls query_output.xls < /dev/null also tried mailx -s "Subject" me@Domain.com < query_output.xls but no attachment received. Could you please help?
Praveen Verma (123 rep)
Jun 13, 2018, 10:26 PM • Last activity: Aug 21, 2023, 07:05 PM
1 votes
1 answers
401 views
-bash: /usr/lib/oracle/19.10/client64/bin/sqlplus: No such file or directory
I'm trying to run Oracle Linux 9(aarch64) on M2 MacBook Air using UTM, so that I can develop my python application that is required to connect to Oracle Database 11g. Because the python app requires Oracle instantclient installed, I installed 3 RPMs(basic, devel, sqlplus) according to:https://docs.o...
I'm trying to run Oracle Linux 9(aarch64) on M2 MacBook Air using UTM, so that I can develop my python application that is required to connect to Oracle Database 11g. Because the python app requires Oracle instantclient installed, I installed 3 RPMs(basic, devel, sqlplus) according to:https://docs.oracle.com/en/database/oracle/oracle-database/19/lacli/installing-ic-arm-packages.html#GUID-1F3D38AD-A4DB-461A-9B50-9FC283C5A7CB ~~~ [kojima@localhost ~]$ sudo dnf list installed | grep instantclient oracle-instantclient19.10-basic.aarch64 19.10.0.0.0-1 @@commandline oracle-instantclient19.10-devel.aarch64 19.10.0.0.0-1 @@commandline oracle-instantclient19.10-sqlplus.aarch64 19.10.0.0.0-1 @@commandline ~~~ SQLplus seems to be successfully installed, but bash complains like: ~~~ [kojima@localhost ~]$ sqlplus -bash: /usr/lib/oracle/19.10/client64/bin/sqlplus: No such file or directory ~~~ But the executable file actually exist. Can someone please explain me what I missed? What am I supposed to do? ~~~ [kojima@localhost ~]$ file /usr/lib/oracle/19.10/client64/bin/sqlplus /usr/lib/oracle/19.10/client64/bin/sqlplus: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=abac9e40cfe83fd8802fb2226289640658b3b024, not stripped [kojima@localhost ~]$ uname -a Linux localhost.localdomain 5.15.0-3.60.5.1.el9uek.aarch64 #2 SMP Wed Oct 19 20:23:09 PDT 2022 aarch64 aarch64 aarch64 GNU/Linux [kojima@localhost ~]$ cat /etc/oracle-release Oracle Linux Server release 9.1 ~~~ # EDIT strace sqlplus gives following: ~~~ [kojima@localhost ~]$ strace sqlplus execve("/usr/lib/oracle/19.10/client64/bin/sqlplus", ["sqlplus"], 0xfffff0bed0a0 /* 32 vars */) = -1 ENOENT (No such file or directory) strace: exec: No such file or directory +++ exited with 1 +++ ~~~ ldd -v /usr/lib/oracle/19.10/client64/bin/sqlplus: ~~~ [kojima@localhost ~]$ ldd -v /usr/lib/oracle/19.10/client64/bin/sqlplus linux-vdso.so.1 (0x0000ffff8e854000) libsqlplus.so => /usr/lib/oracle/19.10/client64/lib/libsqlplus.so (0x0000ffff8e744000) libclntsh.so.19.1 => /usr/lib/oracle/19.10/client64/lib/libclntsh.so.19.1 (0x0000ffff8ba19000) libclntshcore.so.19.1 => /usr/lib/oracle/19.10/client64/lib/libclntshcore.so.19.1 (0x0000ffff8b745000) libnnz19.so => /usr/lib/oracle/19.10/client64/lib/libnnz19.so (0x0000ffff8b24a000) libdl.so.2 => /lib64/libdl.so.2 (0x0000ffff8b229000) libm.so.6 => /lib64/libm.so.6 (0x0000ffff8b188000) libpthread.so.0 => /lib64/libpthread.so.0 (0x0000ffff8b167000) librt.so.1 => /lib64/librt.so.1 (0x0000ffff8b146000) libaio.so.1 => /lib64/libaio.so.1 (0x0000ffff8b125000) libresolv.so.2 => /lib64/libresolv.so.2 (0x0000ffff8b102000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000ffff8b0d1000) libc.so.6 => /lib64/libc.so.6 (0x0000ffff8af23000) /lib64/ld-linux-aarch64.so.1 => /lib/ld-linux-aarch64.so.1 (0x0000ffff8e817000) Version information: /usr/lib/oracle/19.10/client64/bin/sqlplus: libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6 /usr/lib/oracle/19.10/client64/lib/libsqlplus.so: libpthread.so.0 (GLIBC_2.17) => /lib64/libpthread.so.0 libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6 /usr/lib/oracle/19.10/client64/lib/libclntsh.so.19.1: libresolv.so.2 (GLIBC_2.17) => /lib64/libresolv.so.2 libdl.so.2 (GLIBC_2.17) => /lib64/libdl.so.2 libm.so.6 (GLIBC_2.17) => /lib64/libm.so.6 libpthread.so.0 (GLIBC_2.17) => /lib64/libpthread.so.0 libaio.so.1 (LIBAIO_0.4) => /lib64/libaio.so.1 libaio.so.1 (LIBAIO_0.1) => /lib64/libaio.so.1 libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6 /usr/lib/oracle/19.10/client64/lib/libclntshcore.so.19.1: librt.so.1 (GLIBC_2.17) => /lib64/librt.so.1 libgcc_s.so.1 (GCC_3.0) => /lib64/libgcc_s.so.1 libdl.so.2 (GLIBC_2.17) => /lib64/libdl.so.2 libm.so.6 (GLIBC_2.17) => /lib64/libm.so.6 libpthread.so.0 (GLIBC_2.17) => /lib64/libpthread.so.0 libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6 /usr/lib/oracle/19.10/client64/lib/libnnz19.so: libdl.so.2 (GLIBC_2.17) => /lib64/libdl.so.2 libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6 /lib64/libdl.so.2: libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6 /lib64/libm.so.6: ld-linux-aarch64.so.1 (GLIBC_2.17) => /lib/ld-linux-aarch64.so.1 libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6 libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6 /lib64/libpthread.so.0: libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6 /lib64/librt.so.1: ld-linux-aarch64.so.1 (GLIBC_PRIVATE) => /lib/ld-linux-aarch64.so.1 libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6 libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6 /lib64/libaio.so.1: ld-linux-aarch64.so.1 (GLIBC_2.17) => /lib/ld-linux-aarch64.so.1 libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6 /lib64/libresolv.so.2: ld-linux-aarch64.so.1 (GLIBC_2.17) => /lib/ld-linux-aarch64.so.1 libc.so.6 (GLIBC_2.34) => /lib64/libc.so.6 libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6 libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6 /lib64/libgcc_s.so.1: libc.so.6 (GLIBC_2.34) => /lib64/libc.so.6 libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6 /lib64/libc.so.6: ld-linux-aarch64.so.1 (GLIBC_PRIVATE) => /lib/ld-linux-aarch64.so.1 ld-linux-aarch64.so.1 (GLIBC_2.17) => /lib/ld-linux-aarch64.so.1 ~~~ Environment variables: ~~~ # at the bottom of the ~/.bashrc # ... export ORACLE_HOME=/usr/lib/oracle/19.10/client64 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$ORACLE_HOME/lib" export DYLD_LIBRARY_PATH="$ORACLE_HOME/lib:$DYLD_LIBRARY_PATH" export TNS_ADMIN="$ORACLE_HOME/lib/network/admin" export PATH="$ORACLE_HOME/bin:$PATH" export NLS_LANG=Japanese_Japan.AL32UTF8 export SQLPATH="$ORACLE_HOME" export ORACLE_PATH="$ORACLE_HOME" export ORA_NCHAR_LITERAL_REPLACE=TRUE ~~~ ~~~ [kojima@localhost ~]$ echo $ORACLE_HOME /usr/lib/oracle/19.10/client64 [kojima@localhost ~]$ echo $PATH /usr/lib/oracle/19.10/client64/bin:/home/kojima/.local/bin:/home/kojima/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
ernix (121 rep)
Mar 21, 2023, 11:20 PM • Last activity: Mar 25, 2023, 10:19 PM
1 votes
1 answers
95 views
SQL*Plus version not printing in tempfile
I am trying to execute below Unix script to fetch the Oracle version from Windows command prompt using `ssh` command to connect to Unix terminal. ``` #!/use/bin/ksh Freport=/tmp/test.txt cd /usr/oracle2/product/11.2.0/bin echo "Begin" > $Freport set +x /usr/oracle2/product/11.2.0/bin/sqlplus -V >> $...
I am trying to execute below Unix script to fetch the Oracle version from Windows command prompt using ssh command to connect to Unix terminal.
#!/use/bin/ksh
Freport=/tmp/test.txt
cd /usr/oracle2/product/11.2.0/bin
echo "Begin" > $Freport
set +x
/usr/oracle2/product/11.2.0/bin/sqlplus -V >> $Freport
set -x
pwd >> $Freport
echo "Completed" >> $Freport
Windows command prompt output:
Begin
/usr/oracle2/product/11.2.0/bin
Completed
Same script ran in Unix server and got below output. Putty output:
Begin

SQL*Plus: Release 11.2.0.1.0

/usr/oracle2/product/11.2.0/bin
Completed
I want to print the Oracle version in my Windows command prompt output. Windows command prompt execution:
C:\programfiles\PUTTY>putty.exe -ssh uname@ip -pw pwd -m windowsscriptpath/test.sh
Any idea how I can solve this?
Chakkara (37 rep)
Feb 14, 2023, 12:57 PM • Last activity: Feb 17, 2023, 10:05 AM
-1 votes
1 answers
88 views
Pass a linux variable into oracle script
I am trying to pass mount_point details in my oracle script. I am able to pass integer variable using below code but not able to send mount point details in oracle script: sed "s/@@pqr@@/$space/g" tablespace_extend.sql | sqlplus -s "/ as sysdba" BEGIN space:="@@pqr@@"; dbms_output.put_line(space); E...
I am trying to pass mount_point details in my oracle script. I am able to pass integer variable using below code but not able to send mount point details in oracle script: sed "s/@@pqr@@/$space/g" tablespace_extend.sql | sqlplus -s "/ as sysdba" BEGIN space:="@@pqr@@"; dbms_output.put_line(space); END; / When I am using same code to pass mount point details, it is not working. it returns this error message: sed: -e expression #1, char 13: unknown option to `s', mount_point = /u08/dbname/
Divya (1 rep)
Oct 27, 2020, 02:39 PM • Last activity: Nov 3, 2020, 10:50 PM
1 votes
1 answers
2320 views
Inserting into a Oracle table from a shell variable storing thousands of values
I'm trying to insert records into a column in Oracle where the values are passed from a shell variable. The variable itself stores pattern generated from a list of files. This pattern is generated on each iteration inside a for loop. The variable values are each inserted into the table inside the fo...
I'm trying to insert records into a column in Oracle where the values are passed from a shell variable. The variable itself stores pattern generated from a list of files. This pattern is generated on each iteration inside a for loop. The variable values are each inserted into the table inside the for loop. But since the variable reads only one record at a time, it inserts only one row at a time. There are thousands of files being read. The code containing both commands which is ran inside sqlplus and the shell commands is ran as a function. Please find the below for the code:
function call_HEAD_INSERT
{
    FILES=/home/oracle/LOG_*.DAT
    for f in $FILES
    do
      #echo "Processing $f file..."
      # take action on each file. $f store current file name
      
      ptrn=grep "HEAD" $f
      #echo $ptrn
    	
       echo "set feedback off;
             set heading off;
             set serveroutput on size unlimited;
    
             VARIABLE GV_return_code    NUMBER;
                     VARIABLE GV_script_error   CHAR(255);
    
             EXEC :GV_return_code := 0;
    
             WHENEVER SQLERROR EXIT 1
    
             DECLARE
               L_error_message VARCHAR2(255);
            BEGIN
                 insert into user.customer(HEAD) values ('$ptrn');
    			commit;
            EXCEPTION
               WHEN OTHERS THEN
                  ROLLBACK;
                  :GV_return_code := 1;
                  :GV_script_error := SQLERRM;
            END;
             /
    
             print :GV_script_error;
             exit :GV_return_code;
             /" | sqlplus -s ${ORACLE_LOGIN} >> ${logFile}
    		
    done 
    return $?
}
Is there a way to speed up the script or query? I tried giving parallel hint to the query but that didn't really speed up the process. So is there any other way this process can be improved in speed either in script or inside PL/SQL? Ideally I would love to insert all the records in one go while here on each iteration the insert statement adds only one record. Any kind of suggestions are welcome.
AntiNational (13 rep)
Jun 28, 2020, 02:45 PM • Last activity: Jun 28, 2020, 06:05 PM
0 votes
1 answers
515 views
Bind variables in terminal
Is it possible to request a variable directly in the terminal? For example, I want to use command `cat `, but I want the terminal to ask what file name to use. Just like in SQL plus I'm using bind variables for this. Is there any solution for terminal?
Is it possible to request a variable directly in the terminal? For example, I want to use command cat , but I want the terminal to ask what file name to use. Just like in SQL plus I'm using bind variables for this. Is there any solution for terminal?
Bieroed (1 rep)
Jun 17, 2020, 04:29 PM • Last activity: Jun 17, 2020, 05:45 PM
0 votes
1 answers
634 views
Unix command substitution when using sqlplud
Trying to invoke a sql file from unix shells script. ExecuteSql1.sh ``` #!/bin/sh ## steps to get the connection and form it. result=`sqlplus -S ${connectURL} << EOF SET PAGES 0 lines 800 @ /sql/testQuery.sql ${LOGFILE} EOF` echo $result ``` output of the above script (works as expected without exce...
Trying to invoke a sql file from unix shells script. ExecuteSql1.sh
#!/bin/sh
## steps to get the connection and form it.
result=`sqlplus -S ${connectURL} << EOF
SET PAGES 0 lines 800
@ /sql/testQuery.sql ${LOGFILE} 
EOF`

echo $result
output of the above script (works as expected without exception) MODULUS BEFORE: 0 MODULUS AFTER: 16 No errors. ExecuteSql2.sh {**NOTE the starting space is PRESERVED below result variable**}
#!/bin/sh
result=`sqlplus -S ${dbConnect} << EOF
      SET PAGES 0 lines 800
      @ /sql/testQuery.sql ${LOGFILE};
      EOF`

echo $result
When executing ExecuteSql2.sh, the output looks like below: ExecuteSql2.sh: line 147: warning: here-document at line 144 delimited by end-of-file (wanted `EOF') MODULUS BEFORE: 0 MODULUS AFTER: 16 No errors. SP2-0042: unknown command "EOF" - rest of line ignored. -------- using, didn't know when using the `` built in command substitution with space causes this issue. Any specific reason for this? -------- testQuery.sql:
SET SERVEROUTPUT ON SIZE UNLIMITED
set heading off verify off feedback off echo off

SPOOL &1

declare
 modulus NUMBER := 0;
BEGIN
  DBMS_OUTPUT.PUT_LINE('MODULUS BEFORE: '||modulus);

select mod(100,21) into modulus from dual;

DBMS_OUTPUT.PUT_LINE('MODULUS AFTER: '||modulus);

end;
/

SET ECHO ON FEEDBACK ON
SHOW ERRORS
SPOOL OFF
Tim (113 rep)
Apr 29, 2020, 11:46 PM • Last activity: Apr 30, 2020, 12:03 AM
0 votes
1 answers
1098 views
bash script does not continue after executing query with sqlplus
here I'm trying to run a normal query with sqlplus and dump the result into CSV file, then I have another job to do, I facing problem my script does not continue after executing sqlplus query it just views the result and dumps the output into csv file but it does not continue also i don't know how t...
here I'm trying to run a normal query with sqlplus and dump the result into CSV file, then I have another job to do, I facing problem my script does not continue after executing sqlplus query it just views the result and dumps the output into csv file but it does not continue also i don't know how to dump the data without view the result out #!/bin/bash cd /dir/test_dir sqlplus -s test/test <
yong shi (25 rep)
Mar 21, 2020, 06:31 PM • Last activity: Mar 21, 2020, 06:43 PM
1 votes
1 answers
24683 views
Shell script that starts sqlplus utility and executes a query, gathers output
I'm trying to do this: In sample.sh: #!/bin/bash sqlplus / as sysdba select * from dual; And just when I run this shell script, it opens sqlplus utility, but it cannot execute the next line that I have written. When I manually exit out of sqlplus, only then the shell executes the remaining line and...
I'm trying to do this: In sample.sh: #!/bin/bash sqlplus / as sysdba select * from dual; And just when I run this shell script, it opens sqlplus utility, but it cannot execute the next line that I have written. When I manually exit out of sqlplus, only then the shell executes the remaining line and I get error message saying 'Select * from dual' is not a valid command. How can I make the script execute the SQL text *within* the context of sqlplus?
Shantharam Puranik (13 rep)
Feb 20, 2020, 06:48 AM • Last activity: Feb 20, 2020, 06:52 AM
0 votes
2 answers
835 views
Is it possible not to override a file in case of error when redirecting STDOUT?
I have a simple syntactically wrong command like this that is meant to be run on Unix/Linux hosts ``` $ echo "first string $PATH" > out.lst $ ECHO second string %PATH% > out.lst ``` The first line will succeed and fill the out file, whilst the second will fail emptying the previously filled file. *I...
I have a simple syntactically wrong command like this that is meant to be run on Unix/Linux hosts
$ echo "first string $PATH" > out.lst
$ ECHO second string %PATH% > out.lst
The first line will succeed and fill the out file, whilst the second will fail emptying the previously filled file. *I'm trying to find a way to preserve the content of the file in case an error occurs in calling some command whose output is meant to override the file.* The use case is a bit strange: I'm trying to write a portable SQL script for Oracle SQL*Plus that is meant to call commands from the underlying OS that may be either Linux or Windows. Being not possible to detect the OS, I'm calling both the commands for the two platform and trying to make the things work just by not raising the exception. On windows, both lines will succeed and the second will override the first. On Linux, the second line will fail, but I want to preserve the content of the file.
Massimo Pasquini (101 rep)
Jan 23, 2020, 09:26 AM • Last activity: Jan 23, 2020, 10:47 AM
0 votes
0 answers
78 views
Query Oracle database through python
Background: New to python. I have a high security client. Anything on the O/S must go through a lengthy (nearly impossible in some cases) process to be approved by the IA department. I want to convert my bash scripts to python2: 1. I don't want to ask to install python3 2. I don't want to ask to ins...
Background: New to python. I have a high security client. Anything on the O/S must go through a lengthy (nearly impossible in some cases) process to be approved by the IA department. I want to convert my bash scripts to python2: 1. I don't want to ask to install python3 2. I don't want to ask to install cx_Oracle In bash I could do something like this: echo "select user from dual;"|${SQLPLUS} > ${TEMPFILE} Is there a way to do something similar in python2 with the basic tools that are part of RHEL7?
Marinaio (298 rep)
Nov 5, 2019, 02:46 PM • Last activity: Nov 5, 2019, 02:53 PM
0 votes
0 answers
929 views
How to call 'ALTER SESSION' inside a sqlplus call in shell script
I have a requirement to call `ALTER SESSION` command within an existing shell script's SQLPlus block. When I tried to call it as `EXECUTE IMMEDIATE 'alter session set optimizer_dynamic_sampling=5'`, it didn't work: I get the ORA error `ERROR at line 1: ORA-00922: missing or invalid option`. What am...
I have a requirement to call ALTER SESSION command within an existing shell script's SQLPlus block. When I tried to call it as EXECUTE IMMEDIATE 'alter session set optimizer_dynamic_sampling=5', it didn't work: I get the ORA error ERROR at line 1: ORA-00922: missing or invalid option. What am I doing wrong here ? Below is the snippet. sqlplus -s << EOS $CONNECT_STRING Whenever SqlError Exit 45; **EXECUTE IMMEDIATE 'alter session set optimizer_dynamic_sampling=5';** exec PACKAGE.PROCEDURE EOS TIA
Aaron Morales (11 rep)
Oct 31, 2019, 07:18 PM • Last activity: Oct 31, 2019, 11:10 PM
0 votes
0 answers
659 views
How to Assign SQLPLUS output value to Variable from root
I am trying to assign sqlplus output to unix variable as a root user using the following function ``` function sql { su - oracle -c " export ORACLE_HOME=$( "`grep "OraG" /u01/app/oraInventory/ContentsXML/inventory.xml | awk '{print $3}'| cut -d= -f2 | sed 's/\"//g'`"/bin/crsctl status resource -w "(...
I am trying to assign sqlplus output to unix variable as a root user using the following function
function sql {
su - oracle -c "
 export ORACLE_HOME=$( "grep "OraG" /u01/app/oraInventory/ContentsXML/inventory.xml | awk '{print $3}'|  cut -d= -f2 | sed 's/\"//g'"/bin/crsctl status resource -w "((TYPE = ora.database.type) AND (LAST_SERVER = $(hostname -s)))" -f | grep ^ORACLE_HOME= | awk -F= '{ print $2 }' )

   export ORACLE_SID=$( "grep "OraG" /u01/app/oraInventory/ContentsXML/inventory.xml | awk '{print $3}'|  cut -d= -f2 | sed 's/\"//g'"/bin/crsctl status resource -w "((TYPE = ora.database.type) AND (LAST_SERVER = $(hostname -s)))" -f | grep ^USR_ORA_INST_NAME= | awk -F= '{ print $2 }' )

   export PATH=$PATH:$ORACLE_HOME/bin

   SQL_OUTPUT=$( $ORACLE_HOME/bin/sqlplus -s / as sysdba<< OCI2
   connect / as sysdba
   set heading off
   set feedback off
   set linesize 145
   set linesize 145
   set feedback off
   spool /tmp/sqlplus.log
   $1
   spool off
   exit
OCI2
   )
   echo "$SQL_OUTPUT"| grep -v \^$
"
}

SPFILE=$(sql "select value from v\$parameter where name = 'spfile';")
but getting the following error
[root@xxxxxx tmp]# SPFILE=$(sql "select value from v\$parameter where name = 'spfile';")
-bash: /bin/sqlplus: No such file or directory
CoolChap007 (73 rep)
Jul 25, 2019, 05:15 PM
1 votes
0 answers
1264 views
Referencing dynamically created table names in Create statement written in shell script
I need to write a script to automatically generate a month end report. The generation process involved creating tables in database and then accessing them later in the same script to create another temp tables. I managed to create the base table dynamically, but facing problem while creating another...
I need to write a script to automatically generate a month end report. The generation process involved creating tables in database and then accessing them later in the same script to create another temp tables. I managed to create the base table dynamically, but facing problem while creating another temp table using former dynamic table as an reference. Table 1: (Create statement is in an sql file) Create table XYZ as ( Select * from abc ); NOTE: table abc is already present in the system. Thus not much issue in creating table XYZ. Table2: (Create statement is in an sql file) Create table JKL as ( Select distinct list from XYZ ); Now, I am not able to find a way to access table XYZ while creating JKL. I thought of assigning table name XYZ in a variable, but I have many such tables to be created with different tables as a reference, so I dont think creating seperate variable for each table name will be an efficient idea. Following is my shell script to create table 1: #!/bin/ksh #Read the file file_table_map.sql to fetch the sql file name and corresponding table name #file where the info related to create statement, prefix of table name and DB is stored. file_table_lst_map=echo ${abhi_SRC}/file_table_map.lst date_prev=date --d 'last month' +%b"_"%Y RunSQLCMD() { echo "Code came here" echo $file_name echo $table_name echo $db_name sqlplus -s /@${db_name} abc.sql abc DB_Z SQL Command to create table 1 is as follows CREATE TABLE &1 AS ( SELECT to_char(add_months(SYSDATE,-1),'MON_yyyy') as dat FROM DUAL ); Where &1 is table name abc_jan_2018 create table &1 AS ( SELECT * FROM &2 ) where &1 is table name JKL_jan_2018 and &2 will be abc_jan_2018. How to enhance the script to facilitate this functionality?
A.Bhargava (11 rep)
Feb 27, 2018, 04:07 AM • Last activity: Mar 9, 2019, 12:08 PM
2 votes
1 answers
514 views
Executing linux aliases from sqlplus
In sqlplus there is an option to execute standard shell commands, simply by prefixing them with '!'. Example: `SQL>!ps -af` returns expected processes. My question is, is there an option to execute user defined aliases in the same way? So far I tried: 1. In .bash_profile: `alias sample="ps -af"`. 2....
In sqlplus there is an option to execute standard shell commands, simply by prefixing them with '!'. Example: SQL>!ps -af returns expected processes. My question is, is there an option to execute user defined aliases in the same way? So far I tried: 1. In .bash_profile: alias sample="ps -af". 2. In sqlplus SQL>!sample. This doesn't work. /bin/bash: sample: command not found.
Z.Szymon (143 rep)
Feb 17, 2019, 04:23 PM • Last activity: Feb 17, 2019, 07:59 PM
0 votes
1 answers
1276 views
ssh sqlplus command has $ symbol and it gets substituted
I'm Running some SQLPLUS code over ssh. ssh -q node1 'export ORACLE_SID=DB11D_1;ORAENV_ASK=NO;. oraenv >/dev/null 2>&1;sqlplus -s / as sysdba << ENDSQL whenever sqlerror exit 1 alter system set wallet open identified by "Passwo$1"; exit; ENDSQL' It looks like the $1 in the password "Passwo$1" gets s...
I'm Running some SQLPLUS code over ssh. ssh -q node1 'export ORACLE_SID=DB11D_1;ORAENV_ASK=NO;. oraenv >/dev/null 2>&1;sqlplus -s / as sysdba << ENDSQL whenever sqlerror exit 1 alter system set wallet open identified by "Passwo$1"; exit; ENDSQL' It looks like the $1 in the password "Passwo$1" gets substituted. And that's causing the command to fail. The command ends up turning into alter system set wallet open identified by "Passwo" * ERROR at line 1: ORA-28353: failed to open wallet Any idea how do I preserve the "$1" in the SQLPLUS command? I have tried the below - alter system set wallet open identified by \"Passwo$1\"; - alter system set wallet open identified by \\\"Passwo$1\\\"; - alter system set wallet open identified by '\""Passwo$1""\'; I cannot add an escape to the $ symbol in the password. So I can't do - alter system set wallet open identified by "Passwo\$1"; Thanks
A Sanghvi (1 rep)
Dec 6, 2018, 11:03 AM • Last activity: Dec 6, 2018, 02:41 PM
1 votes
2 answers
31177 views
Shell script : Redirect sql query output to a file
Inside a shell script, I have written below sqlq(){ result=`sqlplus -S sss/eee@sid q.sql sqlq q.sql --------------- I need to direct the output to a file. I have tried spool inside q.sql like below but didn't work echo "SPOOL /tmp/test.txt; select * from emp';SPOOL off" > q.sql
Inside a shell script, I have written below sqlq(){ result=`sqlplus -S sss/eee@sid q.sql sqlq q.sql --------------- I need to direct the output to a file. I have tried spool inside q.sql like below but didn't work echo "SPOOL /tmp/test.txt; select * from emp';SPOOL off" > q.sql
Srikanth Yadake (189 rep)
Aug 3, 2016, 07:27 AM • Last activity: Nov 18, 2018, 05:27 PM
1 votes
1 answers
1445 views
bind variable and shell scripting with sqlplus
I wish to execute DMLs using bind variable with shell scripts. For example, something like: #!/bin/bash SH_NUM=10 sqlplus -S test_user/test_pass <<EOD var a number; a:=${SH_NUM} insert into test_table values(a); commit; EOD I'm not sure if this is possible, I can use this approch when using pl/sql b...
I wish to execute DMLs using bind variable with shell scripts. For example, something like: #!/bin/bash SH_NUM=10 sqlplus -S test_user/test_pass <
Nir (1405 rep)
Nov 5, 2018, 03:59 PM • Last activity: Nov 6, 2018, 07:29 AM
4 votes
2 answers
8397 views
SQLplus and Oracle, bad UTF-8 display
I have set export NLS_LANG=Italian_ITALY.UTF8 db is on UTF-8 SELECT * FROM NLS_DATABASE_PARAMETERS NLS_CHARACTERSET |AL32UTF8 But sqlplus displays bad `&#242;` `&#224;` `&#236;` characters. select titolo from generale where titolo like '%%Roma d%%'; TITOLO -------------------------------------------...
I have set export NLS_LANG=Italian_ITALY.UTF8 db is on UTF-8 SELECT * FROM NLS_DATABASE_PARAMETERS NLS_CHARACTERSET |AL32UTF8 But sqlplus displays bad ò à ì characters. select titolo from generale where titolo like '%%Roma d%%'; TITOLO ------------------------------------------------------------ Roma drogata: la polizia non pu�� intervenire must be select titolo from generale where titolo like '%%Roma d%%'; TITOLO ------------------------------------------------------------ Roma drogata: la polizia non può intervenire I have tried AIX and Linux client, all on UTF-8. What do I miss?
elbarna (13690 rep)
May 19, 2015, 09:00 PM • Last activity: Sep 4, 2018, 11:01 AM
0 votes
1 answers
354 views
Different output when executing script manually and via cron/jenkins job
I have a shell script which opens sqlplus and select some data from db containing chinese characters. When I execute it manually, the output contains those characters. When I do it via cron or jenkins job, it displays question marks instead of chinese characters. Any advice ?
I have a shell script which opens sqlplus and select some data from db containing chinese characters. When I execute it manually, the output contains those characters. When I do it via cron or jenkins job, it displays question marks instead of chinese characters. Any advice ?
FunTomas (471 rep)
Apr 25, 2018, 08:58 AM • Last activity: Apr 29, 2018, 01:31 PM
Showing page 1 of 20 total questions