Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting function from plpgsql to C

Status
Not open for further replies.

SkyHigh

Technical User
May 30, 2002
309
CA
Hi

I was wondering if someone may kindly help me convert the following function written in plpgsql into c language:

----------Function---------

CREATE FUNCTION fn_asset_tr_archive() RETURNS OPAQUE AS'

BEGIN

/* TG_OP is the function(UPDATE,DELETE,INSERT) */

INSERT INTO asset_tr_archive
VALUES
(OLD.asset_id, OLD.asset_name, OLD.owner, NEW.owner, NEW.trans_id, OLD.trans_value, NEW.trans_on)
;

/* the record should only be archived whenever the owner changes */

IF NEW.owner != OLD.owner
THEN TG_OP = ''UPDATE'';
RETURN NEW;
END IF;
RETURN OLD;

END;

' LANGUAGE 'plpgsql';

----------Function---------

Your time and help would be much appreciated.
Rgds
Brenda
 
Sorry I posted the wrong one, here is the correct one :

----------Function---------
CREATE FUNCTION fn_asset_tr_archive() RETURNS OPAQUE AS'

BEGIN
IF NEW.owner != OLD.owner
THEN

INSERT INTO asset_tr_archive
VALUES
(OLD.asset_id, OLD.asset_name, OLD.owner, NEW.owner, NEW.trans_id, OLD.trans_value, NEW.trans_on) ;
END IF;
RETURN NEW;
END;

' LANGUAGE 'plpgsql';

---------Function---------

Your time and help would be much appreciated.
Rgds
Brenda
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top