Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> trigger and stored procedure

trigger and stored procedure

From: <hbhondwe_at_hss.hns.com>
Date: Fri, 11 Oct 2002 05:43:35 -0800
Message-ID: <F001.004E69F5.20021011054335@fatcity.com>

Hi,

Can someone pls help me with the following problem?

thanks
harsh

Requirement:

Whenever a row is deleted from a database table, the client application shall get the deletion details. Based on the studies done the following approach is thought to be more appropriate.

  1. Create a trigger on the database table. This trigger will call a stored function.
  2. This function will a call a External C procedure.
  3. All these triggers and functions are defined in next section.

Description of the Table naren_subscribers.

Name                                      Null?    Type
 ----------------------------------------- --------
----------------------------
 USERID                                    NOT NULL NUMBER(38)
 SUBSCRIBER                                         VARCHAR2(30)
 HOST                                      NOT NULL VARCHAR2(100)
 ALIAS                                              VARCHAR2(30)
 AUTHFAILURE                                        NUMBER(38)
 BLOCKSTATUS                                        NUMBER(38)


The trigger is defined as follows

 CREATE OR REPLACE TRIGGER Pre_del_trigger  BEFORE DELETE ON naren_subscribers
 FOR EACH ROW
 declare
 return_value double precision;
 Begin
 return_value := senddata(:old.userid, :old.subscriber);  end;
 /

The function is defined as follows

SQL> CREATE OR REPLACE FUNCTION senddata ( arg1 IN NUMBER,
arg2 IN NUMBER )
return DOUBLE PRECISION AS
EXTERNAL NAME "senddata"
LIBRARY libsenddata
LANGUAGE C;
/

The C procedure is as follows

double senddata (OCINumber USER_ID, OCINumber AUTHFAILURE ) {

   /* This c procedure opens a socket connection to client application
(which needs the information of the deleted row.) and passes this USER_ID
and AUTHFAILURE */.

}

This C procedure is compiled and senddata.so is generated. This .so is placed in oracle server by creating a library libsenddata. All OCI related headers are included in C procedure

Assumptions:

 The function senddata that is defined above is sending arguments as NUMBER. So the equivalent datatype in C is OCINumber.

The problem description:

  1. When I am trying to convert the OCINumber to integer in C procedure using OCI library error is returned.
  2. Or is there any way to do this conversion from NUMBER to equivalent C data type. as well as VARCHAR equivalent C data type.

This message is proprietary to Hughes Software Systems Limited (HSS) and is intended solely for the use of the individual to whom it is addressed. It may contain privileged or confidential information and should not be circulated or used for any purpose other than for what it is intended. If you have received this message in error, please notify the originator immediately. If you are not the intended recipient, you are notified that you are strictly prohibited from using, copying, altering, or disclosing the contents of this message. HSS accepts no responsibility for loss or damage arising from the use of the information transmitted by this email including damage from virus.

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: hbhondwe_at_hss.hns.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L

(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Received on Fri Oct 11 2002 - 08:43:35 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US