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

Home -> Community -> Usenet -> c.d.o.misc -> How to handle object types in C external routines?

How to handle object types in C external routines?

From: Michael Schaefers <schaefe3_at_cs.uni-bonn.spam-remove.de>
Date: Mon, 15 Nov 2004 16:20:58 +0100
Message-ID: <cnahh3$l0g$1@f1node01.rhrz.uni-bonn.de>


Does anybody know how to alter attributes of an object type within an external C routine?

Whenever I alter attributes of a struct, these changes have no effect. Please see my following example:

Let's assume there is an object type

CREATE OR REPLACE TYPE person AS OBJECT (

     NAME VARCHAR2(50),
     AGE  NUMBER,
     LASTVISIT DATE,

     MEMBER PROCEDURE testProc(test BINARY_INTEGER),
) NOT FINAL; The type body declares "testProc" as follows:

CREATE OR REPLACE TYPE BODY person AS

	MEMBER PROCEDURE testProc(test BINARY_INTEGER) AS
	LANGUAGE C
	LIBRARY lib_extproc_demo
	NAME "person_testProc"
	WITH CONTEXT
	PARAMETERS (
		CONTEXT,
		test int,
		test INDICATOR short,
		SELF,
		SELF INDICATOR struct
	);

END; Now I have implemented the C routine "person_testProc" as follows:

void person_testProc (OCIExtProcContext * ctx, int test, short test_ind, person* self, person_ind* self_ind){

...

	// write value of parameter test into attribute "age" of struct:
	OCINumber *agePtr = &self->age;
	error = OCINumberFromInt(err, &test, sizeof(test), OCI_NUMBER_UNSIGNED, 
agePtr);

...

}

My PL/SQL test script is:
DECLARE
        p Person;
BEGIN

	p := NEW Person ('Michael', 25, NULL);
	dbms_output.put_line(p.age); -- should print "25"
	p.testProc(42);
	dbms_output.put_line(p.age); -- should print "42", but prints "25", too!
END; This script print "25" twice, although the testProc method is called and executed without errors...

I am currently runnign Oracle 10g on a Suse 9.1 Professional system

Any suggestions?

Michael Received on Mon Nov 15 2004 - 09:20:58 CST

Original text of this message

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