DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old May 25th, 2006, 02:04 AM
NeenaPaul NeenaPaul is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 3 NeenaPaul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 6 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old June 24th, 2006, 12:55 AM
NeenaPaul NeenaPaul is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 3 NeenaPaul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 6 sec
Reputation Power: 0
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
@

Reply With Quote
  #3  
Old June 25th, 2006, 01:42 AM
NeenaPaul NeenaPaul is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 3 NeenaPaul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 6 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > TYPE in DB2


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway