Hi,
I ve a below structured object TYPE in Oracle to calculate the Simple and Compound interest for an amount.. -
CREATE TYPE pnr_typ AS OBJECT
-
(
-
principle NUMBER,
-
interest NUMBER,
-
year NUMBER,
-
MEMBER FUNCTION si RETURN FLOAT,
-
MEMBER FUNCTION ci RETURN FLOAT,
-
MEMBER FUNCTION prod(invent NUMBER) RETURN NUMBER
-
);
-
/
-
show err
-
-
CREATE TYPE BODY pnr_typ IS
-
-
MEMBER FUNCTION si RETURN FLOAT IS
-
BEGIN
-
RETURN (principle*interest*SELF.year)/100;
-
END; MEMBER FUNCTION ci RETURN FLOAT IS
-
BEGIN
-
RETURN POWER(SELF.principle*(1 + SELF.interest/100), year);
-
END;
-
-
-
MEMBER FUNCTION prod (invent NUMBER) RETURN NUMBER IS
-
BEGIN
-
RETURN (year + invent);
-
END;
-
END;
-
/
-
Show err
-
With in the TYPE i define some attributes like principle, interest, year and more member functions like si, ci, prod to access and modify the TYPE attributes.
This TYPE can be used in
* the column definition while creating a column in a table,
* the procedures or Oracle DB objects as an instance
I would like to know if the TYPE (structured) in DB2 can do the same as the above Oracle TYPE.
Thanks,
Neena
3 5389
Hi ,
I ve successfully created the equivalent for the above Oracle TYPE object in DB2 with the below DB2 code snippet .. - 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
-
@
I do not have an idea how to use this TYPE in tables or SQL queries or Procedures, could any body help me with some simple eg. using this TYPE.
Thanks,
Neena
Now I am able to create tables with the structured TYPE as a column , insertions and selections of the TYPE columns into and from the table and the method calls in a Select query is working fine now,
Could any one help me with the usage of structured TYPEs within a procedure or function...
I dont know how to initialise the TYPE in a function....
Any help on this would be highly appreciated..
Thanks
Sn
With due respects to the experts here I wonder is this (TYPE)too complex ... i dint find any solution for my problem...
Sn :confused:
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ian Taite |
last post by:
Hello,
I'm exploring why one of my C# .NET apps has "high" memory usage, and
whether I can reduce the memory usage.
I have an app that wakes up and processes text files into a database...
|
by: j0mbolar |
last post by:
given this example:
void bar(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
baz(fmt, ap);
va_end(ap);
|
by: RH |
last post by:
Hi,
I am building a windows application that has a feature that retrieves a set
of records when a button is clicked. When the records are being retrieved I
experience a complete system...
|
by: Tim T. |
last post by:
I'm currently working on a report to forecast production for finished goods.
The user can select one or more items to forecast. In addition, they may
select one or more warehouses to view...
|
by: Mark |
last post by:
I want to create a collection class that will be strongly typed (store a
specific object type), be keyed with a case insensitive string, and be able
to access objects stored by index, or...
|
by: jiang.haiyun |
last post by:
Hello all,
when i import SOAPpy, the python crashed and print out 'usage:copy
source destination'.
As follows:
############################
haiyun# python
Python 2.4.1 (#2, Mar 28 2006,...
|
by: nospam_news |
last post by:
I currently get asked about my usage of "auto". What is it for?
The keyword is clearly superflous here.
In contrast to the huge majority of C/C++ developers I write
definitions very explicitly...
|
by: deerchao |
last post by:
I'm developing a WinForms application. It slowly eats up memory, one
client reported that it took 200MB or more, and finnaly crashed. I
myself noticed it's common to use up 30MB memory, but if I...
|
by: ShadowLocke |
last post by:
This is an HTML application that allows you to monitor the CPU Usage (as seen in task manager) for any one task either on the local computer or a remote computer using vbscript. It then alerts you...
|
by: Max2006 |
last post by:
Hi,
To protect my WCF service boundaries, I assign a unique support ticket to
all server side exceptions, log them and send a general FaultException to
client that only include the support...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |