0

I have shell script with following code:

#! /bin/bash

MODEL=$1
declare -a arr=("porsche" "lamborgini" "tesla")

for i in ${arr[@]}
do
sqlplus -s un/pass <<!
set verify off
INSERT INTO tbl1 (par1, par2, par3, datetime_parm)
VALUES('$MODEL', '${arr[i]}', (select count(s) from table i), SYSTIMESTAMP);
COMMIT;
exit;
!
done

For some reason it is overwriting the previous value it gets from the array and i ends up only populating the table with 'tesla'.

Does anyone know what i am doing wrong?

1 Answer 1

1

I figured it out.

#! /bin/bash

MODEL=$1
declare -a arr=("porsche" "lamborgini" "tesla")

for i in ${arr[@]}
do
sqlplus -s un/pass <<!
set verify off
INSERT INTO tbl1 (par1, par2, par3, datetime_parm)
VALUES('$MODEL', '$i', (select count(s) from table i), SYSTIMESTAMP);
COMMIT;
exit;
!
done
Sign up to request clarification or add additional context in comments.

1 Comment

All I had to do is pass variable $i

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.