|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
TYPE in DB2
Hi all,
We have an object 'TYPE' in Oracle that can be declared and defined in the Oracle database and the same can be used within the Database objects. The Oracle TYPE can have data and member functions, member procedures to access the data with in them. can anyone help me in identifying the same in DB2? with thanks n regards. Neena Paul |
|
#2
|
|||
|
|||
|
Hi,
I created a DB2 TYPE as specified below, could any one let me know how could i use this in tables or Procedures. Code:
CREATE TYPE s1.pnr_typ AS
(
principle INT,
interest DECIMAL(5, 2),
year INT
)
NOT FINAL
MODE DB2SQL
METHOD SI()
RETURNS FLOAT
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
NO EXTERNAL ACTION,
METHOD CI()
RETURNS FLOAT
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
NO EXTERNAL ACTION,
METHOD PROD(NUM INT)
RETURNS INTEGER
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
NO EXTERNAL ACTION
@
CREATE METHOD SI()
FOR s1.pnr_typ
RETURN (SELF..principle*SELF..interest*SELF..year)/100
@
CREATE METHOD CI()
FOR s1.pnr_typ
RETURN SELF..principle * POWER((1 + SELF..interest/100), SELF..year)
@
CREATE METHOD PROD(NUM INT)
FOR s1.pnr_typ
RETURN NUM+SELF..year
@
|
|
#3
|
|||
|
|||
|
Now I am able to create tables with the structured TYPE as a column and able to insert and select the TYPE columns from the table... also the method calls in a Select query is working fine now,
Could any one throw the light on the usage of TYPE within a procedure or function... Any help on this would be highly appreciated.. Thanks, Neena |
![]() |
| Viewing: Dev Shed Forums > Databases > DB2 Development > TYPE in DB2 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|