LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can you pass a bash array to sqplus script? (https://www.linuxquestions.org/questions/linux-newbie-8/can-you-pass-a-bash-array-to-sqplus-script-4175518368/)

threezerous 09-12-2014 10:35 AM

Can you pass a bash array to sqplus script?
 
I have a bash script which collects various values and passes them to a sqlplus script as follows

Code:

sqlplus /nolog << EOF
connect $db_name/$db_password@$db_conn
@test.sql $A $B $C $D
exit
EOF

Can I define a bash array as below and call something like @test.sql arg[]?
Code:

arg[0]='A'
arg[1]='B'
arg[2]='C'
arg[3]='D'
@test.sql arg[]


pan64 09-13-2014 03:47 AM

the best thing I can suggest you is to look the man page of bash and look for array handling. It can surely do what you need, but uses different syntax.
Code:

some examples:
a=(A B C D)
echo ${a[0]}
echo ${a[1]}
echo ${a[*]}



All times are GMT -5. The time now is 12:54 AM.