[Progress Communities] [Progress OpenEdge ABL] Forum Post: RE: Getting the string format of ROWID via SQL92

  • Thread starter Thread starter Stefan Drissen
  • Start date Start date
Status
Not open for further replies.
S

Stefan Drissen

Guest
In current versions, the rowid is a 64 bit integer, which in hex is 0x + 16 hexadecimal digits (total length 18). Since sql92 does not have a hex function and I have no idea how to create functions or loops in sql92, I proudly present my highly optimized 'to_rowid' select ;-): select name, '0x' + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 16 ) ) / power( 16, 15 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 15 ) ) / power( 16, 14 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 14 ) ) / power( 16, 13 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 13 ) ) / power( 16, 12 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 12 ) ) / power( 16, 11 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 11 ) ) / power( 16, 10 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 10 ) ) / power( 16, 9 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 9 ) ) / power( 16, 8 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 8 ) ) / power( 16, 7 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 7 ) ) / power( 16, 6 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 6 ) ) / power( 16, 5 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 5 ) ) / power( 16, 4 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 4 ) ) / power( 16, 3 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 3 ) ) / power( 16, 2 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 2 ) ) / power( 16, 1 ), 1 ) + substring( '0123456789abcdef', 1 + mod( cast( rowid as bigint ), power( 16, 1 ) ) / power( 16, 0 ), 1 ) as 'to_rowid' from pub.customers

Continue reading...
 
Status
Not open for further replies.
Back
Top