.
contact contact

DBINFO 202 returns wrong values

 
.
 

Title: DBINFO 202 returns wrong values
Document: 896868896
Author: K.Schäfer
Keywords: FAQ,dbinfo,202,PACKFMT,linux,windows,byte order,UNPACK


DBINFO returns wrong values for number of data entries and data set capacity

On Intel based systems the byte order is different than on a HP-UX based system. The data set capacity and the number of entries are a 32 bit value. Unpacking it as 16 bit values is illegal and does not work on systems with a reversed byte order.

The example code below demonstrates unpacking DBINFO mode 202 results in a platform independend matter:

! DBINFO 202 sample code
  DIM Buf$[34]
  INTEGER S(1:10)
!
  DIM Name$[16],Type$[1]
  INTEGER Entry_len
  DINTEGER Entries,Capacity
!
  Db$="  db"
  DBOPEN(Db$,"",1,S(*))
  IF S(1) THEN Db_err
!
  DBINFO(Db$,"CUSTOMERS",202,S(*),Buf$)
  IF(S(1)) THEN Db_err
  UNPACK USING Fmt;Buf$
Fmt:PACKFMT Name$,Type$,1X,Entry_len,6X,Entries,Capacity
  Entry_len=2*Entry_len
!
  DISP Name$;" ";Type$;Entry_len;Entries,Capacity
  STOP
!
Db_err: DISP "DB: ";DBEXPLAIN$(S(*))
  STOP
 
 
.
 
 
  Privacy | Webmaster | Terms of use | Impressum Revision:   
  Copyright © 1995-2002 Marxmeier Software AG