Can I use SQL along with 4GL ABL code?

Could someone let me know if I could use SQL statement along with 4GL / ABL in a .p / .w?

Should I use a "CURSOR" for this purpose?

Any downside to this approach.

The reason I ask this is because I want to use something like

"SELECT max(empno) FROM emp"

which could not be done using 4gl as I have no index on empno which leaves me with no option but to read through (for each emp) all the records.

Hence I would like to use "SELECT max(empno) FROM emp".

Please let me know.

Thanks
Joel
 

Cringer

ProgressTalk.com Moderator
Staff member
Personally I wouldn't recommend the use of SQL alongside ABL... but if it works? ...
 

TomBascom

Curmudgeon
This is the road to hell. You will only find pain and agony down this road.

The embedded SQL doesn't help you with the no-index problem -- it is still going to scan the entire table. All it does is provide a different syntax. If you start scattering that stuff around in your code you will confuse future maintenance programmers (one of whom might be you) and some of them might get the mistaken idea that they can successfully use SQL inside 4GL programs.

The SQL-92 engine has a no-index table-scan capability. But you do not get that with the embedded SQL-89.

The embedded SQL is occasionally useful for a quick and dirty procedure editor ad-hoc query -- "SELECT COUNT(*) FROM someTable." and the ilk. It makes a nice demo once in a while. But using it in real programs is just begging for trouble.
 

GregTomkins

Active Member
A classic Tom Bascomism!! I'm pinning this to the wall along with 'It made a nice demo. Back in 1985, that is.', referring to dictionary validation expressions.
 
This is the road to hell. You will only find pain and agony down this road.

The embedded SQL doesn't help you with the no-index problem -- it is still going to scan the entire table. All it does is provide a different syntax. If you start scattering that stuff around in your code you will confuse future maintenance programmers (one of whom might be you) and some of them might get the mistaken idea that they can successfully use SQL inside 4GL programs.

The SQL-92 engine has a no-index table-scan capability. But you do not get that with the embedded SQL-89.

The embedded SQL is occasionally useful for a quick and dirty procedure editor ad-hoc query -- "SELECT COUNT(*) FROM someTable." and the ilk. It makes a nice demo once in a while. But using it in real programs is just begging for trouble.

Thanks much for your thoughts Tom.
 
Top