Skip to main content link. Accesskey S
  • Anonymous
  • Log on
  • Help
  • IBM logo
  • IBM Mashup Center wiki
  • All Wikis
  • Home
  • Community Articles
  • Product Documentation
  • Learning Center


Search

Advanced Search

Categories

Tag Cloud

  • 2.0
  • 3.0
  • 3.0.0.1
  • action widgets
  • actions
  • admin
  • administering
  • administration
  • administrator
  • adminstering
  • Ajax
  • AJAX proxy
  • annotate function
  • annotator
  • API
  • api reference
  • benchmark testing
  • catalog
  • configuing
  • configuration
  • configure
  • configuring
  • creating
  • creating mashups
  • data
  • data mashup builder
  • data mashups
  • database
  • DB2
  • demo
  • deploy
  • deployment
  • designing applications
  • developer
  • developing
  • developing mashups
  • developing widgets
  • documentation
  • ECM Widgets
  • editing
  • Enterprise Content Management Widgets
  • errors
  • events
  • examples
  • explanations
  • feed
  • feed mashups
  • feeds
  • format
  • functions
  • getting started
  • greenhouse
  • guide
  • IMS database feeds
  • IMS feeds
  • IMS transaction feeds
  • installation
  • installing
  • mashup
  • MashupHub
  • mashuphub examples
  • mashuphub users guide
  • mashups
  • messages
  • migrating
  • objects
  • operators
  • Oracle
  • pages
  • payload types
  • pdf
  • performance
  • performance tuning
  • planning
  • product
  • programming
  • proxy
  • rest services
  • security
  • service
  • spaces
  • themes
  • troubleshooting
  • tutorial
  • tutorials
  • upgrading
  • user
  • users
  • v1.0
  • v1.1
  • v2.0
  • v2.0.0.2
  • v4.5.2.1
  • video
  • WAR
  • widget
  • widgets
  • widgets
  • wire
  • YouTube
InformationInformation
You are currently viewing machine translated content. IBM translation might be available. Click IBM Translated Product Documentation to see what is available.X


Home > Find Out How > SQL 'IN' Clause equivalent to handle selections from a comma seperated List
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

SQL 'IN' Clause equivalent to handle selections from a comma seperated List 

expanded Abstract
collapsed Abstract
Creating feeds from SQL queries that require use of IN clause along with passing dynamic parameters to be used with IN clause is hard. Here is a simpler way to perform the same function.
Assuming the values in one of the input parameter to a SQL feed is a comma separated list of values.  The latter, for example,
could be generated from a multiple selection drop down or checkboxes.

DB2:

http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0054097.html
 
Example:
 
db2 => select * from testTAB01

ID          CENTER          STATE


          1 ABCD001         ca
          2 ABCD002         mi
          2 XYZZ010         OR
          3 CDEF010         NV
          4 EFGH1010        NM

  5 record(s) selected.
 
db2 =>  select * from testTAB01 where center in ('ABCD001','CDEF010','EFGH1010')

ID          CENTER          STATE


          1 ABCD001         ca
          3 CDEF010         NV
          4 EFGH1010        NM

  3 record(s) selected.
 
Workaround for using this in MashupHub for feed creation:

db2 => select * from testTAB01 where INSTR( 'ABCD001,CDEF010,EFGH1010',center) > 0

ID          CENTER          STATE


          1 ABCD001         ca
          3 CDEF010         NV
          4 EFGH1010        NM

  3 record(s) selected.


Oracle:
 
http://download.oracle.com/docs/cd/B28359_01/olap.111/b28126/dml_functions_1103.htm

Example:
 
SQL> select * from testTAB01;

        ID CENTER          ST


         1 ABCD001         ca
         2 ABCD002         mi
         2 XYZZ010         OR
         3 CDEF010         NV
         4 EFGH1010        NM

SQL> select * from testTAB01 where INSTR( 'ABCD001,CDEF010,EFGH1010',center) > 0;

        ID CENTER          ST


         1 ABCD001         ca
         3 CDEF010         NV
         4 EFGH1010        NM
 
SQL Server:
 
http://msdn.microsoft.com/en-us/library/ms186323.aspx
 
Example:
 
select * from testTAB01
 
id    center    state
1    ABCD001    ca
2    ABCD002    mi
2    XYZZ010    OR
3    CDEF010    NV
4    EFGH1010    NM
 
select * from testTAB01 where CHARINDEX( center,'ABCD001,CDEF010,EFGH1010') >0;
  
id    center    state
1    ABCD001    ca
3    CDEF010    NV
4    EFGH1010    NM
 
As shown above the String ''ABCD001,CDEF010,EFGH1010' is the comma separated values that would typically be used in an IN clause to return all matching rows.  In all the examples the workaround performs the same function. Creating feeds using the same SQL and declaring the relevant url param, this String value can now be dynamic by passing them via the URL param during feed execution.
 
Example:
 
select * from testTAB01 where INSTR( ':cparam',center) > 0 
 
In the above SQL, the 'cparam' declared as the query param to which one can pass the comma separated list of values during feed execution.
As a note if the column values are not distinct, one will have to tune the query to use other supported database functions and get the desired result.

expanded Article information
collapsed Article information
Category:
Find Out How
Tags:

This Version: Version 12 July 12, 2011 8:10:01 PM by Rajesh A Kartha  IBMer

expanded Attachments (0)
collapsed Attachments (0)

 


expanded Versions (12)
collapsed Versions (12)
Version Comparison     
Version Date Changed by               Summary of changes
This version (12) Jul 12, 2011 8:10:01 PM Rajesh A Kartha  
11 Jul 12, 2011 8:09:13 PM Rajesh A Kartha  
10 Jul 12, 2011 8:08:58 PM Rajesh A Kartha  
9 Jul 12, 2011 8:01:48 PM Rajesh A Kartha  
8 Jul 12, 2011 8:01:23 PM Rajesh A Kartha  
7 Jul 12, 2011 6:36:01 PM Rajesh A Kartha  
6 Jul 12, 2011 6:14:40 PM Rajesh A Kartha  
5 Jul 12, 2011 5:18:21 PM Rajesh A Kartha  
4 Jul 12, 2011 5:17:17 PM Rajesh A Kartha  
3 Jul 12, 2011 2:41:58 PM Rajesh A Kartha  
2 Jul 12, 2011 2:06:29 PM Rajesh A Kartha  
1 Jul 12, 2011 2:05:33 PM Rajesh A Kartha  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedSubscribe to RSSHelpAbout
  • All Lotus and WebSphere Portal wikis
  • IBM developerWorks
  • IBM Software support
  • IBM Social Business User Experience Blog
  • IBMSocialBizUX on Twitter
  • IBMSocialBizUX on Facebook
  • Lotus product forums
  • IBM Social Business UX blog
  • IBM Collaboration Solutions
  • Recently added feedRecently added
  • Recently edited feedRecently edited
  • Recently added comments feedRecently Added Comments
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Contact IBM
  • IBM Terms of use
  • Wiki terms of use