oracle - SQL Method to retrieve a value -


in sql, how can create simple method retrieve value object?

here code:

create type currentuser_objtyp object ( currusername varchar2(20), curruserpassword varchar2(20), currusertype varchar2(15) ) / 

how can retrieve value of currusername method?

as oracle sql types allow public attributes there no point in creating getter , setter methods them.

but general principle create member methods:

create type currentuser_objtyp object ( currusername varchar2(20), curruserpassword varchar2(20), currusertype varchar2(15), member function getname return varchar2 ) / 

you need write body implementation, pl/sql:

create type body currentuser_objtyp       member function getname return varchar2         begin          return self.currusername;     end; end; / 

"how call member function in above code?"

to call member function (or procedure) first have instantiate object. there various different ways of using objects, again here simplest:

declare     curruser currentuser_objtyp := new currentuser_objtyp('mr knox', 'password1', 'manager'); begin     dbms_output.put_line('user name '||curruser.getname); end; / 

oracle have devoted entire manual object-relational constructs. should read find out more.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -