Transaction activity

This view shows the transaction activity that occurred in the Adaptive Server, both for the sample interval and the session.

SMC_SIZET transaction_activity_count = 20;
SMC_DATAITEM_STRUCT transaction_activity_view[] = {
{ SMC_NAME_XACT,                 SMC_STAT_VALUE_SAMPLE },
{ SMC_NAME_XACT_DELETE,          SMC_STAT_VALUE_SAMPLE },
{ SMC_NAME_XACT_INSERT,          SMC_STAT_VALUE_SAMPLE },
{ SMC_NAME_XACT_UPDATE,          SMC_STAT_VALUE_SAMPLE },
{ SMC_NAME_XACT_UPDATE_DIRECT,   SMC_STAT_VALUE_SAMPLE },
{ SMC_NAME_XACT,                 SMC_STAT_VALUE_SESSION },
{ SMC_NAME_XACT_DELETE,          SMC_STAT_VALUE_SESSION },
{ SMC_NAME_XACT_INSERT,          SMC_STAT_VALUE_SESSION },
{ SMC_NAME_XACT_UPDATE,          SMC_STAT_VALUE_SESSION },
{ SMC_NAME_XACT_UPDATE_DIRECT,   SMC_STAT_VALUE_SESSION },
{ SMC_NAME_XACT,                 SMC_STAT_RATE_SAMPLE },
{ SMC_NAME_XACT_DELETE,          SMC_STAT_RATE_SAMPLE },
{ SMC_NAME_XACT_INSERT,          SMC_STAT_RATE_SAMPLE },
{ SMC_NAME_XACT_UPDATE,          SMC_STAT_RATE_SAMPLE },
{ SMC_NAME_XACT_UPDATE_DIRECT,   SMC_STAT_RATE_SAMPLE },
{ SMC_NAME_XACT,                 SMC_STAT_RATE_SESSION },
{ SMC_NAME_XACT_DELETE,          SMC_STAT_RATE_SESSION },
{ SMC_NAME_XACT_INSERT,          SMC_STAT_RATE_SESSION },
{ SMC_NAME_XACT_UPDATE,,         SMC_STAT_RATE_SESSION },
{ SMC_NAME_XACT_UPDATE_DIRECT,   SMC_STAT_RATE_SESSION }
};SMC_SIZET num_views = 27;
  SMC_SIZET* view_count = (SMC_SIZET*) malloc (sizeof(SMC_SIZET)
 	* num_views );
  SMC_DATAITEM_STRUCT** view_list = (SMC_DATAITEM_STRUCT**)
 	malloc (sizeof(SMC_DATAITEM_STRUCT*) * num_views );
  SMC_SIZET** view_id_handle_list = (SMC_SIZET**) malloc
 	(sizeof(SMC_SIZET*) * num_views );
  SMC_SIZET* view_id_list = (SMC_SIZET*) malloc
 	(sizeof(SMC_SIZET) * num_views );

  SMC_SIZET  client_id;
  SMC_SIZETP client_id_handle = &client_id;

  SMC_SERVER_MODE server_mode = SMC_SERVER_M_LIVE;
  SMC_CHAR server_name[ 40 ];
  SMC_CHAR user_name[ 40 ];
  SMC_CHAR password[ 40 ];
  SMC_CHAR interfaces_file[ 40 ];

  SMC_RETURN_CODE ret;
  SMC_SIZET refresh_num, view_num, col_num, row_num;

  SMC_SIZET num_refreshes = 10;

  SMC_SIZET  row_count;
  SMC_SIZETP row_count_handle = &row_count;

  SMC_DATAITEM_STRUCTP dataitem_list;
  SMC_DATAITEM_NAME dataitem_name;
  SMC_CHARP dataitem_name_str;
  SMC_DATAITEM_STATTYPE dataitem_stat;
  SMC_CHARP dataitem_stat_str;
  SMC_DATAITEM_TYPE dataitem_type;

  SMC_VALUE_UNION data_union;
  SMC_VALUE_UNIONP data_union_handle = &data_union;
  SMC_CHARP data_str;
  SMC_INT ival;
printf("**************************************************\n");
printf("** Test Driver for SQL Monitor Client Library **\n");
printf("**************************************************\n");
if (argc != 5) 
{
    printf(Usage: testcli <SQLMonitorServer> <user> <password>
 	<"interfaces_file>\n");
    exit(1);
  }

  strcpy(server_name, argv[1]);
  strcpy(user_name, argv[2]);
  strcpy(password, argv[3]);
  strcpy(interfaces_file, argv[4]);

  for(view_num=0; view_num<num_views; view_num++)
  {
    view_id_handle_list[ view_num ] = &(view_id_list[ view_num ]);
  }  

  view_count [  0 ] = cache_perf_sum_count;
  view_list  [  0 ] = cache_perf_sum_view;
  view_count [  1 ] = object_lock_status_count;
  view_list  [  1 ] = object_lock_status_view;
  view_count [  2 ] = object_page_io_count;
  view_list  [  2 ] = object_page_io_view;
  view_count [  3 ] = session_page_cache_stats_count;
  view_list  [  3 ] = session_page_cache_stats_view;
  view_count [  4 ] = sample_page_cache_stats_count;
  view_list  [  4 ] = sample_page_cache_stats_view;
  view_count [  5 ] = session_device_io_count;
  view_list  [  5 ] = session_device_io_view;
  view_count [  6 ] = sample_device_io_count;
  view_list  [  6 ] = sample_device_io_view;
  view_count [  7 ] = device_perf_sum_count;
  view_list  [  7 ] = device_perf_sum_view;
  view_count [  8 ] = engine_activity_count;
  view_list  [  8 ] = engine_activity_view;
  view_count [  9 ] = lock_perf_sum_count;
  view_list  [  9 ] = lock_perf_sum_view;
  view_count [ 10 ] = session_network_activity_count;
  view_list  [ 10 ] = session_network_activity_view;
  view_count [ 11 ] = sample_network_activity_count;
  view_list  [ 11 ] = sample_network_activity_view;
  view_count [ 12 ] = network_perf_sum_count;
  view_list  [ 12 ] = network_perf_sum_view;
  view_count [ 13 ] = session_procedure_cache_stats_count;
  view_list  [ 13 ] = session_procedure_cache_stats_view;
  view_count [ 14 ] = sample_procedure_cache_stats_count;
  view_list  [ 14 ] = sample_procedure_cache_stats_view;
  view_count [ 15 ] = procedure_page_cache_io_count;
  view_list  [ 15 ] = procedure_page_cache_io_view;
  view_count [ 16 ] = process_activity_count;
  view_list  [ 16 ] = process_activity_view;
  view_count [ 17 ] = process_object_page_io_count;
  view_list  [ 17 ] = process_object_page_io_view;
  view_count [ 18 ] = process_detail_locks_count;
  view_list  [ 18 ] = process_detail_locks_view;
  view_count [ 19 ] = process_detail_io_count;
  view_list  [ 19 ] = process_detail_io_view;
  view_count [ 20 ] = process_lock_count;
  view_list  [ 20 ] = process_lock_view;
  view_count [ 21 ] = process_page_io_count;
  view_list  [ 21 ] = process_page_io_view;
  view_count [ 22 ] = process_perf_sum_count;
  view_list  [ 22 ] = process_perf_sum_view;
  view_count [ 23 ] = process_procedure_page_io_count;
  view_list  [ 23 ] = process_procedure_page_io_view;
  view_count [ 24 ] = server_perf_sum_count;
  view_list  [ 24 ] = server_perf_sum_view;
  view_count [ 25 ] = procedure_activity_count;
  view_list  [ 25 ] = procedure_activity_view;
  view_count [ 26 ] = transaction_activity_count;
  view_list  [ 26 ] = transaction_activity_view;

  printf("**********   testing smc_connect()   **********\n");
  ret = smc_connect(server_mode,
                    server_name,
                    user_name,
                    password,
                    interfaces_file,
                    ErrorCallback,
                    0,
                    0,
                    client_id_handle);
  if ( ret != SMC_RET_SUCCESS )
  {
    printf("error returned by smc_connect()\n");
    return (int) ret;
  }
  else
  {
    printf("smc_connect() succeeded\n");
  }
printf("**********   testing smc_create_view()   **********\n");
for(view_num=0; view_num<num_views; view_num++)
{
ret = smc_create_view(client_id,
					view_list[ view_num ],
					view_count[ view_num ],
					(SMC_CHARP) 0,
					view_id_handle_list[ view_num ]);
    if ( ret != SMC_RET_SUCCESS )
    {
      printf("error returned by smc_create_view( %d )\n",
 		view_num);
      return (int) ret;
    }
    else
    {
      printf("smc_create_view( %d ) succeeded\n", view_num);
    }
  }
printf("**********   testing smc_refresh()   **********\n");
for(refresh_num=0; refresh_num<num_refreshes; refresh_num++)
{
    ret = smc_refresh(client_id,
                      (SMC_VOIDP) 0,
                      RefreshCallback,
                      0);
    if ( ret != SMC_RET_SUCCESS )
    {
      printf("error returned by smc_refresh() number %d\n",
 		refresh_num);
      return (int) ret;
    }
    else
    {
      printf("smc_refresh() number %d succeeded\n", refresh_num);
    }

    for(view_num=0; view_num<num_views;  view_num++)
    {
      printf("******   testing smc_get_row_count()   ******\n");
      ret = smc_get_row_count(client_id,
                              view_id_list[ view_num ],
                              row_count_handle);
      if ( ret != SMC_RET_SUCCESS )
      {
        printf("error returned by smc_get_row_count()\n");
        return (int) ret;
      }
      else
      {
        printf("smc_get_row_count( view_id = %d ) = %d\n",
 		view_id_list[view_num], row_count);
      }

      dataitem_list = view_list[view_num];

      /* print dataitem name headers */
      for(col_num = 0; col_num<view_count[ view_num ]; col_num++)
      {
        dataitem_name = (dataitem_list[col_num]).dataItemName;
        dataitem_name_str = LookupDataItemName( dataitem_name );
        printf("Col %d %s\t", col_num, dataitem_name_str);
      }
      printf("\n");

      /* print dataitem stattype headers */
      for(col_num = 0; col_num<view_count[ view_num ]; col_num++)
      {
        dataitem_stat = (dataitem_list[col_num]).dataItemStatType;
        dataitem_stat_str = LookupDataItemStat( dataitem_stat );
        printf("Col %d %s\t", col_num, dataitem_stat_str);
      }
      printf("\n");

      for(row_num = 0; row_num<row_count; row_num++)
      {
        for(col_num = 0; col_num<view_count[ view_num ];
 		col_num++)
        {
          dataitem_name = (dataitem_list[col_num]).dataItemName;
          dataitem_stat = (dataitem_list[col_num]).dataItemStatType;
          dataitem_name_str = LookupDataItemName( dataitem_name );
          ret = smc_get_dataitem_value(client_id,
                                       view_id_list[ view_num ],
                                       &(dataitem_list[col_num]),
                                       row_num,
                                       data_union_handle);
          if ( ret != SMC_RET_SUCCESS )
          {
            printf("error returned by smc_get_dataitem_value()\n");
            return (int) ret;
          }

          smc_get_dataitem_type(&(dataitem_list[col_num]),
                                  &dataitem_type);

          switch(dataitem_type)
          {
            case SMC_DI_TYPE_CHARP:
              printf("Col %d:
 				\"%s\"\t",col_num,data_union.stringValue);
              free( data_union.stringValue );
              break;
            case SMC_DI_TYPE_DOUBLE:
              printf("Col %d:
 				%f\t",col_num,data_union.doubleValue);
              break;
            case SMC_DI_TYPE_ENUMS:
              ival = data_union.intValue;
              switch (dataitem_name)
              {
                case SMC_NAME_LOCK_RESULT_SUMMARY:
                  data_str = LookupLockResultSummary(
 					((SMC_LOCK_RESULT_SUMMARY) ival) );
                  printf("Col %d: \"%s\"\t",col_num, data_str );
                  break;
                case SMC_NAME_LOCK_RESULT:
                  data_str = LookupLockResult(
 					((SMC_LOCK_RESULT) ival) );
                  printf("Col %d: \"%s\"\t",col_num, data_str );
                  break;
                case SMC_NAME_LOCK_STATUS:
                  data_str = LookupLockStatus(
 					((SMC_LOCK_STATUS) ival) );
                  printf("Col %d: \"%s\"\t",col_num, data_str );
                  break;
                case SMC_NAME_LOCK_TYPE:
                  data_str = LookupLockType( ((SMC_LOCK_TYPE)
					ival) );
                  printf("Col %d: \"%s\"\t",col_num, data_str );
                  break;
                case SMC_NAME_OBJ_TYPE:
                  data_str = LookupObjectType( ((SMC_OBJ_TYPE)
					ival) );
                  printf("Col %d: \"%s\"\t",col_num, data_str );
                  break;
                case SMC_NAME_CUR_PROC_STATE:
                case SMC_NAME_PROC_STATE:
                  data_str = LookupProcessState(
					((SMC_PROCESS_STATE) ival) );
                  printf("Col %d: \"%s\"\t",col_num, data_str );
                  break;
                default:
                  printf("Col %d: \"ERR with %s\"\t",col_num,
					dataitem_name_str );
              }
              break;
            case SMC_DI_TYPE_LONG:
              printf("Col %d: %d\t",col_num,
				data_union.longValue);
              break;
            case SMC_DI_TYPE_DATIM:
            case SMC_DI_TYPE_NONE:
            default:
              printf("Col %d: \"ERR with %s\"\t",col_num,
				dataitem_name_str );
          }
        }
        printf("\n");
      }
    }  
  }

  printf("**********   testing smc_disconnect()   **********\n");
  ret = smc_disconnect(client_id);
  if ( ret != SMC_RET_SUCCESS )
  {
    printf("error returned by smc_disconnect()\n");
    return (int) ret;
  }
  {
    printf("smc_disconnect() succeeded\n");
  }

  free(view_count);
  free(view_list);

  return 0;
} 


SMC_VOID
ErrorCallback(
  SMC_SIZET    id,
  SMC_SIZET    error_number,
  SMC_SIZET    severity,
  SMC_SIZET    map_severity,
  SMC_SIZET    source,
  SMC_CCHARP   error_msg,
  SMC_SIZET    state
  )
{
  printf("****************************************\n");
  printf("Inside ErrorCallback()\n");

  printf("id = %d\n", id);
  printf("error_number = %d\n", error_number);
  printf("err severity = %d\n", severity);
  printf("map severity = %d\n", map_severity);
  printf("source = %d\n", source);
  printf("error msg = %s\n", error_msg);
  printf("state = %d\n", state);
  printf("****************************************\n");
  return;  
}


SMC_VOID
RefreshCallback(
  SMC_SIZET   id,
  SMC_VOIDP   user_msg,
  SMC_CHARP   msg
  )
{
  printf("****************************************\n");
  printf("Inside RefreshCallback()\n");

  printf("id = %d\n", id);
  printf("user_msg = %s\n", (SMC_CHARP) user_msg);
  printf("msg = %s\n", msg);

  return;
}


SMC_CHARP
LookupDataItemName(
  SMC_DATAITEM_NAME   value
  )
{
  typedef struct {
    SMC_CHARP           str_name;
    SMC_DATAITEM_NAME   enum_name;
  } DATAITEM_NAME_MAPPER;
  DATAITEM_NAME_MAPPER   dataitem_name_map[] = {
  { "Process ID",							SMC_NAME_SPID },
  { "Kernel Process ID",							SMC_NAME_KPID },
  { "Cache Name", 							SMC_NAME_DATA_CACHE_NAME },
  { "Database ID",							SMC_NAME_DB_ID },
  { "Object ID",							SMC_NAME_OBJ_ID },
  { "Procedure Database ID",							SMC_NAME_ACT_STP_DB_ID }, 
  { "Procedure ID",	 	        					SMC_NAME_ACT_STP_ID },
  { "Procedure Line Number",							SMC_NAME_STP_LINE_NUM },
  { "Lock Type",							SMC_NAME_LOCK_TYPE },
  { "Lock Result",							SMC_NAME_LOCK_RESULT },
  { "Lock Results Summarized",							SMC_NAME_LOCK_RESULT_SUMMARY },
  { "Lock Status",							SMC_NAME_LOCK_STATUS },
  { "Engine Number",							SMC_NAME_ENGINE_NUM },
  { "Page Number",							SMC_NAME_PAGE_NUM },
  { "Device Name",							SMC_NAME_DEV_NAME },
  { "Process State",							SMC_NAME_PROC_STATE },
  { "Login Name",							SMC_NAME_LOGIN_NAME },
  { "Database Name",							SMC_NAME_DB_NAME },
  { "Owner Name",							SMC_NAME_OWNER_NAME },
  { "Object Name",							SMC_NAME_OBJ_NAME },
  { "Object Type",							SMC_NAME_OBJ_TYPE },
  { "Procedure Database Name",							SMC_NAME_ACT_STP_DB_NAME },
  { "Procedure Owner Name",							SMC_NAME_ACT_STP_OWNER_NAME },
  { "Procedure Name",							SMC_NAME_ACT_STP_NAME },
  { "Blocking Process ID",							SMC_NAME_BLOCKING_SPID },
  { "Cache Efficiency",							SMC_NAME_DATA_CACHE_EFFICIENCY },
  { "Cache Hit Pct",							SMC_NAME_DATA_CACHE_HIT_PCT },
  { "Cache Hits", 							SMC_NAME_DATA_CACHE_HIT }, 
  { "Cache Misses",							SMC_NAME_DATA_CACHE_MISS }, 
  { "Cache Spinlock Contention",							SMC_NAME_DATA_CACHE_CONTENTION },
  { "Connect Time",							SMC_NAME_CONNECT_TIME }, 
  { "CPU Busy Percent",							SMC_NAME_CPU_BUSY_PCT },
  { "CPU Percent",							SMC_NAME_CPU_PCT },
  { "CPU Time",							SMC_NAME_CPU_TIME },
  { "Current Engine",							SMC_NAME_CUR_ENGINE },
  { "Current Process State",							SMC_NAME_CUR_PROC_STATE },
  { "Deadlock Count",							SMC_NAME_DEADLOCK_CNT },
  { "Demand Lock",							SMC_NAME_DEMAND_LOCK },
  { "Device Hits",							SMC_NAME_DEV_HIT },
  { "Device Hit Percent",							SMC_NAME_DEV_HIT_PCT },
  { "Device I/O",							SMC_NAME_DEV_IO },
  { "Device Misses",							SMC_NAME_DEV_MISS },
  { "Device Reads",							SMC_NAME_DEV_READ },
  { "Device Writes",							SMC_NAME_DEV_WRITE },
  { "Lock Count",							SMC_NAME_LOCK_CNT },
  { "Lock Hit Percent",							SMC_NAME_LOCK_HIT_PCT },
  { "Lock Status Count",							SMC_NAME_LOCK_STATUS_CNT },
  { "Locks Being Blocked Count",		SMC_NAME_LOCKS_BEING_BLOCKED_CNT },
  { "Code Memory Size",							SMC_NAME_MEM_CODE_SIZE },
  { "Kernel Structures Memory Size",	SMC_NAME_MEM_KERNEL_STRUCT_SIZE },
  { "Page Cache Size",							SMC_NAME_MEM_PAGE_CACHE_SIZE },
  { "Procedure Buffer Size",							SMC_NAME_MEM_PROC_BUFFER },
  { "Procedure Header Size",							SMC_NAME_MEM_PROC_HEADER },
  { "Server Structures Size",							SMC_NAME_MEM_SERVER_STRUCT_SIZE },
  { "Most Active Device I/O", 							SMC_NAME_MOST_ACT_DEV_IO },
  { "Most Active Device Name",							SMC_NAME_MOST_ACT_DEV_NAME },
  { "Net I/O Bytes",							SMC_NAME_NET_BYTE_IO },
  { "Net Bytes Received",							SMC_NAME_NET_BYTES_RCVD },
  { "Net Bytes Sent",							SMC_NAME_NET_BYTES_SENT },
  { "Net Default Packet Size",							SMC_NAME_NET_DEFAULT_PKT_SIZE },
  { "Net Max Packet Size",							SMC_NAME_NET_MAX_PKT_SIZE },
  { "Net Packet Size Received",							SMC_NAME_NET_PKT_SIZE_RCVD },
  { "Net Packet Size Sent",							SMC_	NAME_NET_PKT_SIZE_SENT },
  { "Net Packets Received",							SMC_NAME_NET_PKTS_RCVD },
  { "Net Packets Sent",							SMC_NAME_NET_PKTS_SENT },
  { "Page Hit Percent",							SMC_NAME_PAGE_HIT_PCT },
  { "Logical Page Reads",							SMC_NAME_PAGE_LOGICAL_READ },
  { "Page I/O",							SMC_NAME_PAGE_IO },
  { "Physical Page Reads",							SMC_NAME_PAGE_PHYSICAL_READ },
  { "Page Writes",							SMC_NAME_PAGE_WRITE },
  { "Process State Count",							SMC_NAME_PROC_STATE_CNT },
  { "Timestamp", 							SMC_NAME_TIMESTAMP },
  { "Elapsed Time", 							SMC_NAME_ELAPSED_TIME },
  { "SQL Server Name",							SMC_NAME_SQL_SERVER_NAME },
  { "SQL Server Version",							SMC_NAME_SQL_SERVER_VERSION },
  { "Procedure Elapsed Time",							SMC_NAME_STP_ELAPSED_TIME },
  { "Procedure Hit Percent",							SMC_NAME_STP_HIT_PCT },
  { "Procedure Line Text",							SMC_NAME_STP_LINE_TEXT },
  { "Procedure Execution Count",					SMC_NAME_STP_NUM_TIMES_EXECUTED },
  { "Procedure Logical Reads",							SMC_NAME_STP_LOGICAL_READ },
  { "Procedure Physical Reads",							SMC_NAME_STP_PHYSICAL_READ },
  { "Time Waited on Lock",							SMC_NAME_TIME_WAITED_ON_LOCK },
  { "Transactions",							SMC_NAME_XACT },
  { "Rows Deleted",							SMC_NAME_XACT_DELETE },
  { "Rows Inserted Clustered",							SMC_NAME_XACT_CINSERT },
  { "Rows Inserted",							SMC_NAME_XACT_INSERT },
  { "Rows Inserted Nonclustered",	SMC_NAME_XACT_NCINSERT },
  { "Rows Updated",							SMC_NAME_XACT_UPDATE },
  { "Rows Updated Directly",							SMC_NAME_XACT_UPDATE_DIRECT },
  { (SMC_CHARP)0,			SMC_NAME_NONE }
  };

  SMC_INT    idx = 0;
  SMC_BOOL   match = FALSE;
  while( match == FALSE)
  {
    if ( value == dataitem_name_map[ idx ].enum_name )
      return dataitem_name_map[ idx ].str_name;

    if (dataitem_name_map[ idx ].enum_name == SMC_NAME_NONE )
      return dataitem_name_map[ idx ].str_name;

    idx++;
  } 
}


SMC_CHARP
LookupDataItemStat(
  SMC_DATAITEM_STATTYPE   value
  )
{
  typedef struct {
    SMC_CHARP               str_stat;
    SMC_DATAITEM_STATTYPE   enum_stat;
  } DATAITEM_STAT_MAPPER;

  DATAITEM_STAT_MAPPER   dataitem_stat_map[] = {
  { "Value for Sample",								SMC_STAT_VALUE_SAMPLE },
  { "Value for Session",								SMC_STAT_VALUE_SESSION },
  { "Rate for Sample", 								SMC_STAT_RATE_SAMPLE },
  { "Rate for Session",								SMC_STAT_RATE_SESSION },
  { "Avg for Sample",								SMC_STAT_AVG_SAMPLE },
  { "Avg for Session",								SMC_STAT_AVG_SESSION },
  { (SMC_CHARP)0,		0 }
  };

  SMC_INT    idx = 0;
  SMC_BOOL   match = FALSE;

  while( match == FALSE)
  {
    if ( value == dataitem_stat_map[ idx ].enum_stat )
      return dataitem_stat_map[ idx ].str_stat;

    if (dataitem_stat_map[ idx ].enum_stat == 0 )
      return dataitem_stat_map[ idx ].str_stat;

    idx++;
  } 
}


SMC_CHARP
LookupLockResult(
  SMC_LOCK_RESULT   value
  )
{
  typedef struct {
    SMC_CHARP         str_lock_res;
    SMC_LOCK_RESULT   enum_lock_res;
  } LOCK_RESULT_MAPPER;

  LOCK_RESULT_MAPPER lock_result_map[] = {
  { "granted",								SMC_LOCK_R_GRANTED },   
  { "notneeded",								SMC_LOCK_R_NOTNEEDED },
  { "waited",								SMC_LOCK_R_WAITED },
  { "didntwait",								SMC_LOCK_R_DIDNTWAIT },
  { "deadlock",								SMC_LOCK_R_DEADLOCK },
  { "interrupted",								SMC_LOCK_R_INTERRUPTED},
  { (SMC_CHARP)0,	0 }
  };

  SMC_INT    idx = 0;
  SMC_BOOL   match = FALSE;

  while( match == FALSE)
  {
    if ( value == lock_result_map[ idx ].enum_lock_res )
      return lock_result_map[ idx ].str_lock_res;

    if (lock_result_map[ idx ].enum_lock_res == 0 )
      return lock_result_map[ idx ].str_lock_res;

    idx++;
  } 
}
SMC_CHARP
LookupLockResultSummary(
  SMC_LOCK_RESULT_SUMMARY   value
  )
{
  typedef struct {
    SMC_CHARP                 str_lock_ressum;
    SMC_LOCK_RESULT_SUMMARY   enum_lock_ressum;
  } LOCK_RESULT_SUMMARY_MAPPER;

  LOCK_RESULT_SUMMARY_MAPPER lock_result_summary_map[] = {
  { "granted",								SMC_LOCK_RS_GRANTED },   
  { "notgranted",								SMC_LOCK_RS_NOTGRANTED },   
  { (SMC_CHARP)0,	0 }
  };

  SMC_INT    idx = 0;
  SMC_BOOL   match = FALSE;

  while( match == FALSE)
  {
    if ( value == lock_result_summary_map[ idx ].enum_lock_ressum )
      return lock_result_summary_map[ idx ].str_lock_ressum;

    if (lock_result_summary_map[ idx ].enum_lock_ressum == 0 )
      return lock_result_summary_map[ idx ].str_lock_ressum;

    idx++;
  } 
}

SMC_CHARP
LookupLockStatus(
  SMC_LOCK_STATUS   value
  )
{
  typedef struct {
    SMC_CHARP         str_lock_status;
    SMC_LOCK_STATUS   enum_lock_status;
  } LOCK_STATUS_MAPPER;

  LOCK_STATUS_MAPPER lock_status_map[] = {
  { "held_blocking",							SMC_LOCK_S_HELD_BLOCKING },
  { "held_notblocking",							SMC_LOCK_S_HELD_NOTBLOCKING },
  { "requested_blocked",							SMC_LOCK_S_REQUESTED_BLOCKED },
  { "requested_notblocked",							SMC_LOCK_S_REQUESTED_NOTBLOCKED },
  { (SMC_CHARP)0,		0 }
  };

  SMC_INT    idx = 0;
  SMC_BOOL   match = FALSE;

  while( match == FALSE)
  {
    if ( value == lock_status_map[ idx ].enum_lock_status )
      return lock_status_map[ idx ].str_lock_status;

    if (lock_status_map[ idx ].enum_lock_status == 0 )
      return lock_status_map[ idx ].str_lock_status;

    idx++;
  } 
}


SMC_CHARP
LookupLockType(
  SMC_LOCK_TYPE   value
  )
{
  typedef struct {
    SMC_CHARP       str_lock_type;
    SMC_LOCK_TYPE   enum_lock_type;
  } LOCK_TYPE_MAPPER;

  LOCK_TYPE_MAPPER lock_type_map[] = {
  { "ex_tab",								SMC_LOCK_T_EX_TAB },
  { "sh_tab",								SMC_LOCK_T_SH_TAB },
  { "ex_int",							SMC_LOCK_T_EX_INT },
  { "sh_int",							SMC_LOCK_T_SH_INT },
  { "ex_page",							SMC_LOCK_T_EX_PAGE },
  { "sh_page",							SMC_LOCK_T_SH_PAGE },
  { "upd_page",							SMC_LOCK_T_UP_PAGE },
  { (SMC_CHARP)0,	0 }
  };

  SMC_INT    idx = 0;
  SMC_BOOL   match = FALSE;

  while( match == FALSE)
  {
    if ( value == lock_type_map[ idx ].enum_lock_type )
      return lock_type_map[ idx ].str_lock_type;

    if (lock_type_map[ idx ].enum_lock_type == 0 )
      return lock_type_map[ idx ].str_lock_type;

    idx++;
  }