Topic
3 replies Latest Post - ‏2013-05-17T16:08:25Z by Sreeharsha_Naik
SystemAdmin
SystemAdmin
3105 Posts
ACCEPTED ANSWER

Pinned topic Problem ( SELECT statement)

‏2013-02-01T11:02:21Z |
CREATE TABLE testTab ( id int, name varchar(10))
insert into testTab values(1, 'chandu'), (2, 'abc')

I will pass the set of ids( like '2,3,5' ) from front-end

How to get the ids which does not existed in my table testTab

Output should be:
3
5
Please help on this... Am new to DB2 z/OS

Note: Only the SELECT statement( not to use temparory tables and all)
Please help
Updated on 2013-02-26T15:51:11Z at 2013-02-26T15:51:11Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    3105 Posts
    ACCEPTED ANSWER

    Re: Problem ( SELECT statement)

    ‏2013-02-18T16:17:06Z  in response to SystemAdmin
    Hi,
    You need to code a stored procedure which can do the work for you!
    -Rajesh Prabhu
    • SystemAdmin
      SystemAdmin
      3105 Posts
      ACCEPTED ANSWER

      Re: Problem ( SELECT statement)

      ‏2013-02-26T15:51:11Z  in response to SystemAdmin
      is this still relevant?
      what is the maximum number of ids you will be sending in that list?
      do you need this implemented using a single SQL statement or do you want to use a procedure?
  • Sreeharsha_Naik
    Sreeharsha_Naik
    1 Post
    ACCEPTED ANSWER

    Re: Problem ( SELECT statement)

    ‏2013-05-17T16:08:25Z  in response to SystemAdmin

    From what I have understood - You should have a mechanism to save all of your ID's somewhere - Another DB2 Table perhaps ? If your table 1 contains the actual information and table 2 contains all the ID's - You can write a SELECT query :

    SELECT ID FROM TABLE1 WHERE ID NOT IN ( SELECT ID FROM TABLE 2 ) ;

    Regards,
    Sreeharsha Naik