Length of the entered value

535 pts.
Tags:
AS/400
AS/400 Query
Hi group, How to get the length of the entered value using WRKQRY? I am querying a file, the name field is defined as 15 characters. I need to get all those records whose name is greater than 10 Characters. Could anyone please help me how to write a query? Regards, M

Answer Wiki

Thanks. We'll let you know when a new response is added.

SQL is much faster and has more options that Querry/400. Consider switching over to that. In eiter case, Tom is correct, use SubString to look at positions 11 to 15 of the field and compare that to blank.

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    The best answer is to stop using Query/400. It's old, almost obsolete, slow and can't handle many of the system's newer features. You should use QM Query instead.   One possible way with Query/400 would be to check a substring of the last five characters. If the last five characters are all blank, the length must be 10 or less.   Tom
    125,585 pointsBadges:
    report
  • ToddN2000
    If you must use WRKQRY, then create a new field named OVER10 for an example. Define it as SUBST(NAME,11,5). Then select the records where OVER10 is not blank.Try that.
    9,700 pointsBadges:
    report
  • TomLiotta
    I'll emphasize that QM Query has two user interface modes: SQL and 'Prompted'. It's not necessary to know SQL for QM Query if 'Prompted' mode is used. It is very similar to the Query/400 interface, but it has an option to convert prompted queries to access the underlying SQL. -- Tom
    125,585 pointsBadges:
    report
  • mvrkrishna
    Thanks group. The issue got resolved. As suggested by Tom I would like to  learn QM query. Please suggest good sites to learn.
    535 pointsBadges:
    report
  • TomLiotta
    I would like to  learn QM query.   Ways to learn depend on whether you have the SQL Dev Kit installed on your system or not. If it's installed, it's fairly easy, especially if you already know Query/400.   Run the STRQM command to access QM. A menu with four options should appear. The options allow you to work with queries, forms, tables and profiles.   One difference that takes a little to get used to is that QM breaks its work into two parts. The first part is the query where tables and columns are selected and operated on. The output of a query is a result set. The second part is the form where printed output is defined. A result set is the input to a form. A form is essentially a report definition. Although you generally never see it, a result set effectively has a record format that fits it.   There is a default report for any query, so it's often not necessary to define one. However, if two queries create output in the same format, they can be used as input for the same report form. A single form can be fed by any query that creates an appropriate result format. That means that a report form can be used over and over with different queries.   Also. a single query definition can be used with any report forms that accept its result set format. A query might be printed in many different ways, so it can be reused for many reports.   Finally, a query can be output to an outfile.   First learning attempt should be simple. If your system has common options installed, a query is easy.   Run STRQM, and take option 1 to work with queries. When the 'Work with...' display opens, make sure the creation mode at the top says PROMPT. If it says SQL, use F19 to switch the mode.   Now, enter option 1 to create a query named CUSTCDT, and press <Enter>. The query definition page should appear, and it should look a lot like Query/400's page. Take option 1 against 'Specify files' and press <Enter>. Specify the QCUSTCDT file in library QIWS, and press <enter>.   (You can name your query whatever you want, and specify any file in any library. I'm only using names that should be available to almost everyone.)   After you pressed <Enter>, you should be back at the definition page. You now have a complete query that you can run. (It hasn't been saved and compiled yet, but it's available to run.) Press F5='Run report' to see what it looks like. On the Run Query page, set the output to 1=Display, and press <Enter>. Your query output should show on your display.   You can figure out how to exit from QM, so I'll leave it there.   Details about using QM require a couple .PDFs. These can be accessed through the Queries and reports topic. The last one listed, Query Manager Use, is the one you'll need first. It will probably be the only one you'll use. But if you get seriously into programming around it, you'll eventually want the Query Management Programming manual also.   Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following