Passing parameter more than 9

Hi,

I've written a script where eleven parameter to be passed from command line
which is inserting into an oracle table,

it is working but the tenth and 11th parameter are not accepting as given
it is referring to 1st parameter.

HERE IS THE SCRIPT

#!/bin/ksh
#set -o

echo $*
sqlplus -s /nolog <<ENDOFSQL
connect dbinfo/dbinfo123@dbtrac1t;

insert into dbinfo.test1(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11) values ('$1',sysdate,'$3','$4','$5',$6,'$7','$8','$9','$10','$11');
commit;

ENDOFSQL

CALLING THE SCRIPT AS >>>>>>>>>>>

. ./insert-test.sh one two three four five 06 seven eight nine ten eleven

HERE IS WHAT IT IS INSERTING INTO THE TABLE............NOTE 10TH and 11TH COLUMN VALUE

SQL> select * from dbinfo.test1 order by 2;

C1         C2                             C3    C4    C5                 C6 C7    C8         C9         C10        C11
---------- ------------------------------ ----- ----- ---------- ---------- ----- ---------- ---------- ---------- ----------
one        07-JUL-13 12.58.38.000000 PM   three four  five                6 seven eight      nine       one0       one1
one        07-JUL-13 01.00.28.000000 PM   three four  five                6 seven eight      nine       one0       one1
one        07-JUL-13 01.02.34.000000 PM   three four  five                6 seven eight      nine       one0       one1

any help is appreciated...........

Write ${10} instead of $10 , ${11} instead of $11 , etc,

I am not sure about ksh, but as far as bash is concerned, the single quotes DO NOT allow shell interpretation. That is to say, whatever is inside single quotes will be inserted into your database as a fixed string.
If you want to insert the values of your variables, you should consider hergp's suggestion or use doble quotes as in the following example:

insert into dbinfo.test1(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11) values ("$1",sysdate,"$3","$4","$5","$6","$7","$8","$9","$10","$11");

Hope it helps. Let us know if you need further help.

1 Like

Thanks very much , this is working ..................

That is only the case if the here-document delimiter is quoted.

$ X=1
$ cat << !
> '$X'
> !
1

$ cat << "!"
> '$X'
> !
'$X'