Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2010
    Posts
    5

    Unanswered: How to put a limit on the file size in k-shell

    Hi All,

    I want to store 32KB of file in Oracle DB into CLOB field. I am not able to insert more than 32KB of file into CLOB. So i want to put a limit on the file size. I am using k shell.

    My file size will dynamically increase its size, i want to check the file size if it is more than 32KB then put a limit and insert the same in CLOB field of DB.

    I am using k-shell.

    Please find below my code which is in place and let me know where i am doing wrong:

    I am getting
    ERROR:
    ORA-01756: quoted string not properly terminated


    myLogCount=$(cat $LogFile | wc -c)
    echo "myLogCount in Actual Program::::: $myLogCount"
    if [ $myLogCount -gt 32767 ]
    then
    awk '{n=n+length+1}
    n <= 32500
    n > 32500 {n-=length;print substr($0,1,(32500-n));exit}
    ' $LogFile > $myTmpLog

    echo "Log file too large to view, Please visit server to view complete log" >> $myTmpLog
    myTmpLogCount=$(cat $myTmpLog | wc -c)
    br_Update_Proxy_Job_Run_Status "$Comment" \
    "$RunStatusId" \
    "$WarningCount" \
    "" \
    "" \
    "" \
    "" \
    "" \
    "$RptTotalRejectedDF" \
    "$myTmpLog" \
    "$ProxyJobStatus"
    else
    br_Update_Proxy_Job_Run_Status "$Comment" \
    "$RunStatusId" \
    "$WarningCount" \
    "" \
    "" \
    "" \
    "" \
    "" \
    "$RptTotalRejectedDF" \
    "$LogFile" \
    "$ProxyJobStatus"
    fi









    Please help appreciate if any sample script

    Thanks,
    Raj

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    You could simplify the size calculation by using the find command.
    eg.

    yes=`find ./ -name clob.file -size -63` # ( ie 63 x 512 char blocks or -32768c)
    if $yes is equal to clob.file, the file is less than 32kb

    If you want to save the first 32k of the file

    dd if=clob.file of=clob.32k -bs=32k -count=1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •