I'm trying to use Python to call dbcc procbuf() to find tables that cached stored procedures modify by looking for return rows like:
LOCK STRATEGY FOR INSERT
db=11 obj=124002793 lock=exclusive intent stat=0x0
But, in the following Python program, no results get returned from the dbcc procbuf command (works fine using isql). Any SAP Python experts who might know why? (eg., fancy message handler options?)
#!/opt/python-3.8/bin/python
import sys
python_path_for_sybase=os.getenv("SYBASE")+"/"+os.getenv("SYBASE_OCS")+"/python/python34_64r/lib"
sys.path.append(python_path_for_sybase)
import sybpydb
server="MYSERVER"
db="mydb"
connection = sybpydb.connect(
servername='MYSERVER', user='mylogin', password='mypassword',
dsn='ChainXacts=false;ScriptName=mytest.py')
cursor=connection.cursor()
dbcc_procbuf_sql="""
dbcc traceon(3604)
# params are dbid, proc, ...
dbcc procbuf (16,"myproc", 1, 1, 1)
"""
cursor.execute(dbcc_procbuf_sql)
return_rows=[]
try:
return_rows=cursor.fetchall()
except sybpydb.ProgrammingError as myerror:
print("Error calling fetchall. Probably no rows found")
if( len(return_rows) > 0 ):
for return_row in return_rows:
print("Returned row = "+return_row)
# This returns a "not callable" error
# for message in connection.messages():
# print("dbcc procbuf msg: "+message)
cursor.close()
connection.close()