0

I write this simpe test.ksh scipt:

#!/bin/ksh

TEST=$(cat $1 )
sqlplus -S *****/*****@*****<<- EOF
set define off;
SET SQLBLANKLINES ON;
INSERT INTO DBADOC.TEST
(
        "TEST"
)
 VALUES
(
      q'[ $TEST ]'
)
;
commit;
EOF

exit

Now if i run it with a simple file (3 lines without special char):

./test.ksh /home/oracle/scripts/test.txt
1 row created.


Commit complete.

It runs perfectly.

If I choose a complex file (with blank lines and special character ), it doesn't work:

./test.ksh /home/oracle/scripts/check_free_space_dg.ksh
SP2-0734: unknown command beginning "# ========..." - rest of line ignored.
SP2-0734: unknown command beginning "# @(#) NOM..." - rest of line ignored.
SP2-0734: unknown command beginning "# @(#) GRU..." - rest of line ignored.
SP2-0734: unknown command beginning "# @(#) DES..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
[...]
0

SQL-Plus doesn't support hash as a comment character. You can use these to make comments:

  • REM or REMARK at the beginning of a line
  • -- (double dashes) at the beginning of a line
  • or paired /* with */ for block comment, as seen in C.
4
  • I don't use comment in sqlplus in my test.ksh script. The commented rows (#) are in the file that i want upload in the database
    – Michele M
    Dec 18 '20 at 8:40
  • None of that seems to be in the examples you've pasted in.
    – chicks
    Dec 18 '20 at 14:45
  • I don't show the content of the uploaded file. check_free_space_dg.ksh is a bash scritp but i used it for test. I have diffent bash files to upload with different content. I can't post here all my shell scripts.
    – Michele M
    Dec 21 '20 at 13:35
  • The commented rows that you want to upload to the database appear to be the problem. Your shell script looks fine. Getting the SQL to fit SQL-Plus' idea of what an acceptable comment is seems like the solution.
    – chicks
    Dec 21 '20 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.