I'm having issues understanding the example and this may be important
to understand the issue. The query you show:
insert into tab select * from tab_old where sr = ( select max(i.sr)
from tab_old i );
would select from tab_old only the records where "sr" matches the max value... is that really what you're doing?
Apart from that:
1- Is the new table name the same as the application uses? In other
words, are you doing something like:
1) rename existing_table to existing_table_old;
2) create table existing_table (...);
3) begin work;
4) lock table...
If yes, between 2 and 4 you may get INSERTs You should create the new
table as "existing_table_new" do the process and at the end do "rename existing_table_new to existing_table"
Regards.
....
On Fri, Oct 13, 2017 at 1:18 PM, KAMRAN HAQ <khaq@i2cinc.com> wrote:
We used similar script as following to replace a table with new table(existing table was approaching to max pages limit). Bothtable.
tables are locked and an insert statement with maximum serial column
value from existing table is inserted in new table to keep the
serial in accordance with existing
Still we get 7 rows with serial number 1 to 7 before our inserted value.We
got inserts in that table almost every second but how inserts was successful by a non dba user while table was locked?
Script
------
create table tab_new(
sr serial
, val varchar(20)
);
begin work;
lock table tab in exclusive mode;
lock table tab_new in exclusive mode; rename table tab to tab_old;
rename table tab_new to tab; insert into tab select * from tab_old
where sr = ( select max(i.sr) from tab_old i ); commit;
if max value was 123456 then we found following sequence in newly
created table now "tab" after rename 1, 2, 3, 4, 5, 6, 7, 123456,
123457 ...
IDS 12.1FC7 on SunOS
************************************************************ *******************
Forum Note: Use "Reply" to post a response in the discussion forum.
--
Fernando Nunes
Portugal
http://informix-technology.blogspot.com
My email works... but I don't check it frequently...
************************************************************ *******************
Forum Note: Use "Reply" to post a response in the discussion forum.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 483 |
Nodes: | 16 (2 / 14) |
Uptime: | 196:45:48 |
Calls: | 9,601 |
Calls today: | 2 |
Files: | 13,682 |
Messages: | 6,152,226 |