Solved

The EXISTS Method. Compare objects for equal.

Posted on 2009-03-31
7
297 Views
Last Modified: 2013-12-18
Here is some psuedo code. I am trying to determine if an element exists in an object. However every variation on the comparison type format brings an error.
0
Comment
Question by:Caputo
  • 4
  • 3
7 Comments
 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
please post the code too
0
 

Author Comment

by:Caputo
Comment Utility
Sorry, that the second time thats happened here. I use the code snippet, review and submit and it doesnt come thru. Any way here it is,

CREATE OR REPLACE TYPE STAT_OBJ AS OBJECT
(
  CLT_DOC       VARCHAR2(6 BYTE),
  CLT_LSTNM     VARCHAR2(19 BYTE),
  CLT_FSTNM     VARCHAR2(10 BYTE),
  CSE_CRT_NUM   VARCHAR2(9 BYTE),
  CSE_CSE_ID    CHAR(1 BYTE),
  CSE_SEQ_NM    NUMBER(2),
  CSE_OFF_TYP   CHAR(1 BYTE),
  OFF_STAT      VARCHAR2(26 BYTE),
  CSE_STS_SEQ   NUMBER(2),
  OFF_HST_STAT  VARCHAR2(26 BYTE),
  CSE_STS       VARCHAR2(2 BYTE),
  STATUS_DT     NUMBER(8),
  REPORT        VARCHAR2(100 BYTE)
);
CREATE OR REPLACE TYPE STAT_T AS TABLE OF STAT_OBJ;

stat stat_t;
the_list stat_t;

IF the_list.EXISTS(stat (x)) THEN

    null;
   
END IF;


PLS-00306: wrong number or types of arguments in call to 'EXISTS'
0
 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
what are you trying to determine exists?

you have 2 tables   "the_list" and "stat"

to determin if element 10 exists you would do...

the_list.exists(10)
or
stat.exists(10)

you are using checking if element number "stat(x)"  exists with "the_list

but stat(x) isn't a number, it's another object (of type stat_obj)

what is it you are trying to do with "stat(x)"  ?





0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 

Author Comment

by:Caputo
Comment Utility
I am trying to determine if the data in element stat (x) exists-matches anywhere in the_list table
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 125 total points
Comment Utility
ah...

ok for that you will have to iterate though the_list and check each element yourself

for i in 1..the_list.count loop
    IF stat(x).clt_doc = the_list(i).clt_doc
   AND stat(x).clt_lstnm = the_list(i).clt_lstnm
   AND stat(x).clt_fstnm = the_list(i).clt_fstnm
   AND stat(x).cse_crt_num = the_list(i).cse_crt_num
   AND stat(x).cse_cse_id = the_list(i).cse_cse_id
   AND stat(x).cse_seq_nm = the_list(i).cse_seq_nm
   AND stat(x).cse_off_typ = the_list(i).cse_off_typ
   AND stat(x).off_stat = the_list(i).off_stat
   AND stat(x).cse_sts_seq = the_list(i).cse_sts_seq
   AND stat(x).off_hst_stat = the_list(i).off_hst_stat
   AND stat(x).cse_sts = the_list(i).cse_sts
   AND stat(x).status_dt = the_list(i).status_dt
   AND stat(x).report = the_list(i).report
    THEN
        matches := 'Yes';
    END IF;
end loop;
0
 

Author Closing Comment

by:Caputo
Comment Utility
Thank you,
0
 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
glad I could help
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Read about achieving the basic levels of HRIS security in the workplace.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to recover a database from a user managed backup

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now