5 Replies Latest reply on Mar 1, 2012 4:59 AM by Sudheendra-Oracle

    ORA-01031:Insufficient Privileges error when I am trying to use ALERT_QUE

      I am working on SYS.ALERT.QUE for getting system alerts. I am using ODP in C# for connecting to Oracle database with username = SYSTEM, but when I am trying to enque or deque any message from SYS.ALERT.QUE, its gives an error ORA-01031:Insufficient Privileges. I am not able to understand how to assign SYSDBA privileges to SYSTEM and access ALERT_QUE for getting system alerts. I am posting my code below, plz have a look and let me know whats wrong with the code. I am able to connect to databse using SYSTEM, do I need to use username = SYS for accesing ALERT_QUE of database? Plz let me know whats the solution.

      OracleConnection con = new OracleConnection(constr);

      // Create queue
      OracleAQQueue queue = new OracleAQQueue("sys.alert_que", con);

      // Open connection

      // Begin txn for enqueue
      OracleTransaction txn = con.BeginTransaction();

      // Set message type for the queue
      queue.MessageType = OracleAQMessageType.Raw;

      // Prepare message and RAW payload
      OracleAQMessage enqMsg = new OracleAQMessage();
      byte[] bytePayload = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
      enqMsg.Payload = bytePayload;
      OracleAQAgent[] agent = new OracleAQAgent[1];

      agent[0] = new OracleAQAgent("SUBSCRIBER1");
      enqMsg.Recipients = agent;
      enqMsg.SenderId = new OracleAQAgent("SENDER1");

      // Prepare to Enqueue
      queue.EnqueueOptions.Visibility = OracleAQVisibilityMode.OnCommit;

      // Enqueue message

      The code throws exception at line "queue.Enqueue(enqMsg);" saying ORA-01031:Insufficient Privileges

      Edited by: 916462 on Feb 27, 2012 3:31 AM