11. Maintaining Storage Structures : Overflow Management : Overflow and ISAM and Hash Tables : Example: Showing Overflow Distribution
 
Share this page                  
Example: Showing Overflow Distribution
The sample code shown here can be customized to show overflow distribution. Each time a primary page is encountered, the tid’s value grows by 512. If a primary page has associated overflow pages, the tid’s value jumps by more than 512. So if you run the embedded SQL/C program shown in Sample Code to Show Overflow, the output looks like that shown in Output from Sample Code.
Sample Code to Show Overflow
page_val = 0; 
exec sql select key, tid
    into :key_val, :tid_val
    from tablename
exec sql begin;
  if (tid_val == page_val) 
  { 
    printf("Primary Page %d, tid = %d,",(page_val/512)+1, tid_val);
    printf(" Starting key value = %d0", key_val);
    page_val = page_val + 512;
    old_tid_val = tid_val;
    overflow_page = 0;
  }
  else
  {
    if (tid_val > old_tid_val + 1)
  {
      overflow_page++;
      printf("\n Overflow page %d,tid = %d0",over_page,tid_val);
    }
    old_tid_val = tid_val;
  }
exec sql end;
Output from Sample Code
Primary Page 1, tid = 0, Starting Key Value = 123
 Overflow page 1,tid = 2048 
 Overflow page 2,tid = 2560 
 Overflow page 3,tid = 3072 
 Overflow page 4,tid = 3584 
Primary Page 2, tid = 512, Starting Key Value = 456 
 Overflow page 1,tid = 4096 
 Overflow page 2,tid = 4608 
 Overflow page 3,tid = 5120 
 Overflow page 4,tid = 5632