---
title: "DB2 SQL: How to check Host-variables (1 of 2)"
description: "In this blog, you can find how to give an Array in WHERE clause of IN list. This way of using saves CPU time. Hence improve performance."
url: https://srinimf.com/2011/12/15/db2-where-in/
date: 2011-12-15
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2011/12/pexels-photo-574285.jpeg?fit=1880%2C1253&ssl=1
categories: ["DB2"]
tags: ["db2", "WHERE IN"]
type: post
lang: en
---

# DB2 SQL: How to check Host-variables (1 of 2)

I have got an interesting topic on ***DB SQL WHERE*** clause. The below way of SQL improves [DB2 performance](https://srinimf.com/2015/01/11/top-db2-performance-tuning-interview-questions/). The below query tells [how to](https://srinimf.com/2020/02/16/beginners-tutorial-on-embedding-sql/) use ARRAY of variables in ***‘IN’*** list.

[https://srinimf.com/](https://srinimf.com/)[2011](https://srinimf.com/2012/01/01/2011-in-review/)/12/21/db2-where-in-2-of-2/

Ex:  

**WHERE  ABS_TD  IN (:WS-LIST)**

[https://srinimf.com/](https://srinimf.com/)[2014](https://srinimf.com/2013/12/26/cloud-computing-trends-in-2013-and-future-in-2014/)/05/02/db2-fetch-queryno-optimize/

Let’s assume WS-LIST has (A,B,C,D), then cursor will fetch all matching results into [result table](https://srinimf.com/2014/08/05/db2-programming-with-cursors-part1-of-2/). The fetch executes one by one row.

Related[DB2 Fetch ideas on how to optimize result](https://srinimf.com/2012/05/02/db2-fetch-rules/)

Here, we need to make sure, the data type of subordinate item (WS-LIST), should be DCLGEN data type.

**Ex:  **

**05 WS-LIST Redefined WS-LIST-INP1**

**                 10 LIST-ONE  PIC  s9(4) COMP**.

Related Posts

- [DB2 Tutorial For Software Developers (5 of 5)](https://srinimf.com/2015/08/16/mainframe-db2-tutorial-for-software-developers-5-of-5/)DateAugust 16, 2015
- [DB2: What is Atomic in SQL Query](https://srinimf.com/2013/09/06/db2-multi-row-insert-into-a-table/)DateSeptember 6, 2013
- [DB2-Undefined Unusable Host Variable](https://srinimf.com/2011/12/11/db2hostvariable/)DateDecember 11, 2011

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2011%2F12%2F15%2Fdb2-where-in%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2011%2F12%2Fpexels-photo-574285.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=DB2%20SQL%3A%20How%20to%20check%20Host-variables%20%281%20of%202%29)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2011/12/15/db2-where-in/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2011/12/15/db2-where-in/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2011/12/15/db2-where-in/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2011/12/15/db2-where-in/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20DB2%20SQL%3A%20How%20to%20check%20Host-variables%20%281%20of%202%29&body=https%3A%2F%2Fsrinimf.com%2F2011%2F12%2F15%2Fdb2-where-in%2F&share=email)
-

### Like this:

Like Loading…
