2

i'm using an Amazon Work Space and i use a VPN to connect via SSH Ubuntu 16.04 instance. I use python to do a connection an Oracle Database 11g, i need to use cx_Oracle Continuous Query Notification and i founded this code looking on the internet from this page http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/oow10/python_db/python_db.htm:

import cx_Oracle 


def DCNCallback(message): 
    print "Notification:" 
    for tab in message.tables: 
        print "Table:", tab.name
        for row in tab.rows: 
            if row.operation & cx_Oracle.OPCODE_INSERT: 
                print "INSERT of rowid:", row.rowid
            if row.operation & cx_Oracle.OPCODE_DELETE: 
                print "DELETE of rowid:", row.rowid
            if row.operation & cx_Oracle.OPCODE_UPDATE: 
                print "UPDATE of rowid:", row.rowid

con = cx_Oracle.Connection("pythonhol/welcome@localhost/orcl",
                       events = True) 
subscriptionInsDel = con.subscribe(callback = DCNCallback, 
       operations = cx_Oracle.OPCODE_INSERT | cx_Oracle.OPCODE_DELETE 
                    | cx_Oracle.OPCODE_UPDATE, 
       rowids = True) 
subscriptionInsDel.registerquery('select * from mytab') 
raw_input("Hit Enter to conclude this demo\n") 

I copied this example and tried to run on my Ubuntu instance, it does not have any error but when i insert/update/deleted some row on the oracle database nothing happened on the Ubuntu terminal.

What can i do ?

  • Hi, has CQN been enabled on the oracle server? Your non-sys user will need to be enabled for cqn notifications, eg ```GRANT CHANGE NOTIFICATION TO user_name; ```. If that has been done, when you run your python script, perform an insert/update/delete in your mytab table, do you see any output from the python script? – Lingster Jul 19 '18 at 09:40

1 Answers1

0

Has CQN been enabled on the oracle server?

Your non-sys user will need to be enabled for cqn notifications, eg:

GRANT EXECUTE ON DBMS_CQ_NOTIFICATION TO user_name; GRANT CHANGE NOTIFICATION TO user_name;

If that has been done, when you run your python script, perform an insert/update/delete in your mytab table, do you see any output from the python script? see here for more details: https://docs.oracle.com/cd/B28359_01/appdev.111/b28424/adfns_cqn.htm#CHEIFAEJ

Lingster
  • 977
  • 10
  • 21