Solved

The EXISTS Method. Compare objects for equal.

Posted on 2009-03-31
7
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 74

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 74

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 74

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 74

Expert Comment

by:sdstuber
ID: 24029866
glad I could help
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
"Disruption" is the most feared word for C-level executives these days. They agonize over their industry being disturbed by another player - most likely by startups.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

696 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