Мы разрабатываем программу миграции. В БД почти 80 миллионов записей. Код выглядит следующим образом:
static int mymigration(struct progargs *args)
{
exec sql begin declare section;
const char *selectQuery;
const char *updateQuery;
long cur_start;
long cur_end;
long serial;
long number;
char frequency[3];
exec sql end declare section;
selectQuery = "select * from mytable where number >= ? and number <= ? for update of frequency ,status";
updateQuery = "update mytable set frequency = ?, "
" status = ? "
" where current of my_cursor";
cur_start= args->start;
cur_end = args->end;
exec sql prepare my_select_query from :selectQuery;
/* Verify the sql code for error here */
exec sql declare my_select_cursor cursor with hold for my_select_query;
exec sql open my_select_cursor using :cur_start, :cur_end;
/* Verify the sql code for error here */
exec sql prepare my_update_query from :updateQuery;
/* Verify the sql code for error here */
while (1)
{
number = 0;
serial = 0;
memset(frequency,0,sizeof(frequency));
exec sql fetch my_select_cursor into number,:serial,:frequency;
if (sqlca.sqlcode != SQL_OK)
break;
exec sql execute my_update_query using :frequency, :frequency;
}
exec sql close my_select_trade_cursor;
}
При реализации этого мы получаем сообщение об ошибке «-255». Мы нашли одно решение - добавить работу и совершить работу. Поскольку у нас большой объем данных, это может загромождать журнал транзакций.
Есть ли другое решение этой проблемы? Веб-сайт IBM для informix показывает правильное использование.
Заранее оцените помощь.
Спасибо, Мэтью Лиджу
UPDATE MyTable SET (frequency, status) = (0, 0);
? Вы можете добавить «ГДЕ номер› =? И число ‹=? ' предложение тоже, если оно вам нужно (с 80 миллионами строк, вероятно, будет целесообразным). - person Jonathan Leffler   schedule 22.02.2010