Hello,
In an Oracle 10g database I am trying to learn how to use Objects in PL/SQL. I have to say the code examples in the docs leave much to the imagination.
I thought, let me try to emulate a simple msgbox() object. I want to initialize it, set a property value and then extract a property value. I feel like I am a million miles away.
Psuedo Code thus far ...
Can anyone please share how you have coded set and get values and called a method from a standard PL/SQL procedure or function?
Thanks for you advice,
JT
In an Oracle 10g database I am trying to learn how to use Objects in PL/SQL. I have to say the code examples in the docs leave much to the imagination.
I thought, let me try to emulate a simple msgbox() object. I want to initialize it, set a property value and then extract a property value. I feel like I am a million miles away.
Psuedo Code thus far ...
Code:
create or replace TYPE msgbox AS OBJECT (
Title varchar2(50),
Message varchar2(500),
MEMBER FUNCTION setMsg(pTitle IN varchar2 DEFAULT 'msgbox()') RETURN msgbox,
MEMBER PROCEDURE displayMsg
);
create or replace TYPE BODY msgbox AS
MEMBER FUNCTION setMsg(pTitle IN varchar2) RETURN msgbox AS
oMsgBox msgbox := SELF; -- initialize to "current" object
BEGIN
oMsgBox.Title := pTitle;
RETURN oMsgBox;
END;
MEMBER PROCEDURE displayMsg AS
BEGIN
htp.p(oMsgBox.Title);
END;
END;
create or replace PROCEDURE TESTM AS
mb msgbox := new msgbox('Title','Message');
BEGIN
mb.setMsg('My Title','My Messsage.');
htp.p( mb.displayMsg() );
EXCEPTION
WHEN OTHERS THEN
htp.p('An error has occured on this page.');
END TESTM;
Can anyone please share how you have coded set and get values and called a method from a standard PL/SQL procedure or function?
Thanks for you advice,
JT