Search code examples
sybaseofflinesap-ase

Checking status2 value in sybase


I am fetching status2 value in sybase using the following query

select name, status, status2 FROM sysdatabases

After fetching the status2 value I am converting it into 16 bit binary value and checking the 4th and 5th bit to check if the database is offline. The problem arises when a database has abort tran on log full set as true and the value of status2 is -32767. This sets all the bits to 1. Is the method that I have followed to check if a database is offline correct?

I am using the below doc for reference http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36274.1550/html/tables/X42615.htm


Solution

  • I received the below response in SAP community

    1> create database test 2> go CREATE DATABASE: allocating 1536 logical pages (3.0 megabytes) on disk 'master' (1536 logical pages requested). Database 'test' is now online.

    1> select convert(binary(2), status2), status2 from sysdatabases where name = "test" 2> go status2 ------ ------- 0x8000 -32768

    (1 row affected) 1> sp_dboption test, 'abort tran', true 2> go Database option 'abort tran on log full' turned ON for database 'test'. Running CHECKPOINT on database 'test' for option 'abort tran on log full' to take effect. (return status = 0) 1> select convert(binary(2), status2), status2 from sysdatabases where name = "test" 2> go status2 ------ ------- 0x8001 -32767

    (1 row affected)

    To test whether either "offline" bit was on, I would check if (status2 & 48 > 0 )