require'oci8'conn=OCI8.new('username','password','DB')co_la_sql="""
SELECT co.containername, la.stdmrgebatch
FROM container co
INNER JOIN a_scheduledata sd on sd.scheduledataid=co.scheduledataid
INNER JOIN a_lotattributes la ON la.containerid=co.containerid
WHERE co.batchno IS NULL AND la.stdmrgebatch IS NOT NULL
AND la.stdmrgebatch like 'M%'
"""containernames=[]stdmrgebatch=[]conn.exec(co_la_sql)do|r|containernames<<r[0]stdmrgebatch<<r[1]endcontainernames.each_with_indexdo|id,i|sql="UPDATE container co SET co.batchno='#{stdmrgebatch[i]}', co.changecount=co.changecount+1 WHERE co.containername IN ('#{id}')"putssql+";\n"num_rows=conn.exec(sql)puts"#{num_rows} rows updated."endconn.exec"commit"conn.logoff