You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AS400中WRKQRY如何用CONCAT匹配含制表符的文本字段?

How to Find Rows with Tab Characters in WRKQRY (AS/400)

Got it, since you already have the STRSQL logic working, let's translate that into WRKQRY's interactive record selection rules. Here are two straightforward methods to make this happen:

Method 1: Use the POSITION Function (Simpler Check)

This method checks if a tab character (CHR(9)) exists anywhere in your text field by looking for its position:

  1. Open WRKQRY and either create a new query or edit an existing one.
  2. After selecting your target library and table, navigate to the Select Records screen (from the Define Query menu, choose option 3).
  3. Press F6=Add condition to create a new selection rule.
  4. Instead of picking a field directly, press F11=Display expressions to enter a custom condition.
  5. Enter this expression (replace YOUR_FIELD with your actual text field name):
    POSITION(CHR(9) IN YOUR_FIELD) > 0
    
    • CHR(9) generates the tab character (matches what you used in STRSQL).
    • POSITION() returns the index of the tab in the field; if it's greater than 0, the tab exists.
  6. Save the condition, finish setting up your query (like selecting which fields to display), and run it. You'll get all rows where the field contains a tab.

Method 2: Replicate the STRSQL LIKE Logic

If you prefer to mirror your original STRSQL query, WRKQRY uses || as the concatenation operator (instead of CONCAT):

  1. Follow steps 1-3 from Method 1 to get to adding a new condition.
  2. In the condition setup:
    • For Field, select your text field.
    • For Comparison, choose LIKE.
    • For Value, enter this expression:
      '%' || CHR(9) || '%'
      
    • This concatenates wildcards (%) around the tab character, just like your STRSQL query.
  3. Save and run the query—this will behave exactly like your STRSQL statement.

Quick Notes

  • Make sure your field is a character/text type (not numeric or date) since we're checking for text characters.
  • If CHR(9) didn't work for some reason (unlikely since your STRSQL works), confirm your system's tab character code—EBCDIC systems sometimes use CHR(5), but your existing query proves CHR(9) is correct for your environment.

内容的提问来源于stack exchange,提问作者Wilson Pauly

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:37:27