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 5399
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
periodically. What happens, is that the app reads the contents of a
text file line by line into an ArrayList. Each element of the ArrayList
is a string...
|
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 degradation, including other programs that
become unresponsive.
Here's what I found while the retrieval process is running:
Using the Windows Task...
|
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 breakdowns for as well as one or more
customers.
Now, the report iterates through the selected items in the finished good
listbox. For each item that it...
|
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 sequentially (in the order stored) via
"For Each".
I know I could code this from scratch - or derived from a number of
framework classes, but I'm not sure...
| |
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, 21:00:14)
20040728] on freebsd5
Type "help", "copyright", "credits" or "license" for more information.
usage:copy source destination
|
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 like that:
int main(char argc, char *argv, char *env) {
try {
auto Exception mainException(1);
mainException.setErrNo(42);
|
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 minimize it
(all the Forms will Hide, only a NotifyIcon is shown at the System
Notification Area), the memory usage comes down to 8MB immediately....
|
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 when that process has gone idle. I put it together this morning because I was tired of starting a program on remote computer, and continuously reconnect...
|
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 ticket.
Support ticket is just a GUID that comes along with the exception log at the
server side.
From WCF programming best practice, What would be...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |