×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

SQL code -> 4GL code

SQL code -> 4GL code

SQL code -> 4GL code

(OP)
I created code in SQL that works.  I then used the same code in 4GL but it doesn't work...no errors just the wrong answer.  Does anyone know where I might look to find the problem?

RE: SQL code -> 4GL code

(OP)
SQL:
SELECT COUNT(*)
  FROM table1
 WHERE NOT EXISTS
 (SELECT item e
    FROM table2, table3
        WHERE prod_S_dept = filter_itema
        and prod_cat = filter_itemb
        and itemc = itemd)

4GL:
SELECT COUNT(*)
  FROM table1
 WHERE NOT EXISTS
 (SELECT item e
    FROM table2, table3
        WHERE prod_S_dept = filter_itema
        and prod_cat = filter_itemb
        and itemc = itemd)

The code is identical yet the results are different.  I understand that SQL is Diff't from 4GL but what I'm trying to understand is why the diff't results?  Pls understand this code sits in other  code which runs without a problem when the SQL is not in it

RE: SQL code -> 4GL code

First, you don't tell us what the 4GL error is so I'm just guessing.

SQL statements are executed in a different context than in 4GL.  Executing in SQL is probably done in dbaccess/isql which returns the count.

In 4GL, typically the count in placed in a 4GL variable:

CODE

.
.
DEFINE cnt INTEGER

SELECT COUNT(*)INTO cnt
  FROM table1
 WHERE NOT EXISTS
 (SELECT item e
    FROM table2, table3
        WHERE prod_S_dept = filter_itema
        and prod_cat = filter_itemb
        and itemc = itemd)

# and continue with your program
.
.


   

RE: SQL code -> 4GL code

Be careful to preface all your fields with the table name.  If one of your variables happens to have the same name as a field name 4gl will use the variable over the field name.


If you want to debug your result using the code that olded gave you, you may want to add this after your query:

DISPLAY "Count is: ",cnt
SLEEP 5

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close