Hi All,
Requesting help what approach is better of the two in terms of performance and Why ( if there is any difference ) or are they one and they same and only different in terms of syntax only.
A) To invoke a function with passing self as IN OUT nocopy
B) Passing the same invoking object as IN OUT NOCOPY.
@
(In My Approach I Have To Pass An Object Having Almost 30 Attributes And I Have To Assign Values To Few Attributes of the object in few member functions to which object will be passed)
I have an object created as
CREATE OR REPLACE TYPE my_obj AS OBJECT
(
NAME VARCHAR2(100),
CONSTRUCTOR FUNCTION my_obj RETURN SELF AS RESULT,
MEMBER FUNCTION put_name(SELF IN OUT NOCOPY my_obj) RETURN PLS_INTEGER,
MEMBER FUNCTION insert_name(v_my_obj IN OUT NOCOPY my_obj) RETURN
PLS_INTEGER,
MEMBER PROCEDURE get_name
);
/
CREATE OR REPLACE TYPE BODY MY_OBJ IS
CONSTRUCTOR FUNCTION my_obj RETURN SELF AS RESULT IS
BEGIN
NULL;
RETURN;
END;
MEMBER FUNCTION put_name(SELF IN OUT NOCOPY my_obj) RETURN PLS_INTEGER IS
BEGIN
self.name := 'my_name_in_self';
RETURN 1;
END put_name;
MEMBER FUNCTION insert_name(v_my_obj IN OUT NOCOPY my_obj)
RETURN PLS_INTEGER IS
BEGIN
v_my_obj.name := 'my_name_in_Alias';
RETURN 1;
END insert_name;
MEMBER PROCEDURE get_name IS
BEGIN
dbms_output.put_line(self.name);
END;
END;
/
a) Stub 1 invoking put_name :
declare
v my_obj := my_obj();
ret_val number;
begin
ret_val:= v.put_name;
v.get_name;
end;
o/p : my_name_in_self
a) Stub 2 invoking insert_name:
declare
v my_obj := my_obj();
ret_val number;
begin
ret_val:= v.insert_name(v);
v.get_name;
end;
o/p : my_name_in_Alias
Which is a better approach to use put_name or to use insert_name function .
I have to manipulate the object when passed to any of the function.
Thanks in Advance,
Regards,
Gaurav R