Oracle Sql Loop Through Select Statement In Sqlite