Solved

Help on 4GL syntax

Posted on 2008-06-16
4
2,112 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
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction: I have seen many questions on EE and elsewhere, asking about how to find either gaps in lists of numbers (id field, usually) ranges of values or dates overlapping date ranges combined date ranges I thought it would be a good …
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now