Solved

Help on 4GL syntax

Posted on 2008-06-16
4
2,144 Views
Last Modified: 2013-12-25
I'm very new to 4GL in Progress OpenEdge 10.1 very familiar with SQL92. My question is this. Is there a IN condition within a WHERE clause in 4GL?

I want to convert the following SQL statement into 4GL:
SELECT jc_job.kco, jc_job_num, jc_costcode.jcc_cost
FROM jc_job INNER JOIN ON jc_job.job_num = jc_costcode.job_num
WHERE kco IN (11,12,16,17)




0
Comment
Question by:marcorus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 51

Accepted Solution

by:
Mark Wills earned 100 total points
ID: 21881363
According to the manual you can... that is... using the SQL syntax - which is supported.

IN Predicate
The IN predicate can be used to compare a value with a set of values. If an IN predicate specifies
a query expression, then the result table it returns can contain only a single column.
This is the syntax for an in_predicate:
Syntax
expression [ NOT ] IN
{ (query_expression) | (constant , constant [ , ... ] ) }
address.state IN (MA, NH)

Have a look at : http://www.psdn.com/library/servlet/KbServlet/download/112-102-99/dmsrf.pdf

But you may want the APL reference...
0
 

Assisted Solution

by:Memnoch76
Memnoch76 earned 100 total points
ID: 21967480
Solution 1: The CAN-DO() function can compare a field's value to a list of values to return only what you want and can be used as part of a where clause.  Be careful how you use this especially in large tables because this particular phrase won't participate in index selection and will rely on what the rest of your where clause is constructed of.  If this is a relatively small table <1000 records you probably wouldn't notice much of an impact if it was scanning the full index.

ex. ... WHERE CAN-DO("11,12,16,17",jc_job.kco) ...

Solution 2: Create a DO block around your FOR EACH statement stepping through each of the values of the list and assign that to a variable and then check that as an equality match in your where clause.

ex. (see code snippet)

It's also a good idea to always check what index(es) your queries are resolving to by using the COMPILE statement's XREF option and in the xref file verify that all the lines that execute a "SEARCH" contain a valid index and not "WHOLE-INDEX" to keep your queries as efficient as possible.

DEF VAR i AS INT NO-UNDO.
DEF VAR ii AS INT NO-UNDO.
DEF VAR c_kco_list AS CHAR INIT "11,12,16,17" NO-UNDO.
DEF VAR c_kco AS CHAR NO-UNDO.
 
ii = NUM-ENTRIES(c_kco_list).
 
DO i = 1 TO ii:
  kco = ENTRY(i,c_kco_list).
  FOR EACH jc_job NO-LOCK
    WHERE jc_job.kco = c_kco
    ...
    :
    ...
  END.
END.

Open in new window

0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question