Search code examples
oracle-databasesqlplusclob

Insert a large string to a Column type CLOB from a shell script in Oracle sqlplus


I want to write a shell script that connects to my oracle db and updates a column type clob. The value for this clob is read from a file (which is an xml) and taken into a variable from my script and the query is executed from sqlplus.

I have already written a script which reads a file-abc.xml which has about 30000 characters. The connection is working okay as I've executed some other insert queries with no issue

#!/bin/sh
value=$(<abc.xml)
query="UPDATE MY_CLOB_TABLE SET MY_CLOB_COLUMN=TO_CLOB('$value') WHERE MY_OTHER_COLUMN='AnotherColumn';"
echo $query | sqlplus -s $ORACLE_CON_STRING 

I get an error saying

Input truncated to 7499 characters
SP2-0027: Input is too long (> 2499 characters) - line ignored

How can I insert a large file like this to a clob?


Solution

  • Please check below post and try to modify query into multiple lines

    https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4789399600346029472