Solved

The EXISTS Method. Compare objects for equal.

Posted on 2009-03-31
7
310 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
ID: 24028842
please post the code too
0
 

Author Comment

by:Caputo
ID: 24028899
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
ID: 24029060
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:Caputo
ID: 24029151
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
ID: 24029690
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
ID: 31564806
Thank you,
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 24029866
glad I could help
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about achieving the basic levels of HRIS security in the workplace.
Messaging apps are amazing tools with the power to do a lot of good, but the truth is the process of collaborating with coworkers requires relationships established through meaningful communication - the kind of communication that only happens face-…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

773 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