Execute sql statment in korn shell

I am fairly new to writing scripts, and have gotten a lot of help from this site in the past with many of the posts.
I have a question/issue with a script I am attempting to write and have a question regarding executing an sql statement inside of a loop (do while). I have in the past written scripts where script syntax and logic and then has one or more SQL statements, but not intermixed.
I am on HP-UX, running INFORMIX and we use dbaccess to call the DB.
The issue that I am having is in regards to using a counter in a loop and executing an sql that contains the value of the counter.
I have played around already with the redirect (>>$op<<!!!) but still getting errors on a �unmatched <<�
And when I seem to resolve that; the sql wont execute..
I am trying this in a loop because I need to update 2+ million records { and wanted to get a simple select working first} and don�t want to sit and update and execute individually many many times - I can�t run the range to high as I will take up all of the locks, so I am starting with 100K records at a time.

Any direction, guidance, help would be greatly appreciated

 x=1
 xa=1
 while ((x<xa)) ; do
    print -n \\rx = $x
    sleep 1
     dbaccess ${DB}@${DBSERV} >>${op} <<!!! 
       set isolation dirty read;
        SELECT
          <field_1>
          ,<field_2>
        FROM
          <table>
        Where
           <field> between '$x' and '$xa'
                   ;
                 !!!
                 
     ((x=x+100000))
 done
  
 

The here document is part of your problem
The last !!! has to be in column #1 - the leftmost column. Or the leading <<!!! needs a dash : <<-!!!

Next: I think your redirection needs to be outside the top !!! - that is to the right of it not inside.

I do not know Informix, but generally speaking, massive selects do not use locking, massive updates do. So a periodic commit releases the locks.

This answer was predicated on your using a modern shell.