?
Solved

Help on 4GL syntax

Posted on 2008-06-16
4
Medium Priority
?
2,158 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 400 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 400 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

765 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