Debug GUI - Is there any way to see the query string behind

Posted by guymills on 03-Mar-2017 02:58

Hi All

I'm just trying to provide some debug to developers converting old (ADM1) screens to backend APIs.  I want to provide  a way of right-clicking on a browse (on a global trigger), and displaying the query behind the data.  "FOR EACH customer WHERE customer.state = 'NY'" - that kind of thing.

For dynamic queries against DB tables, all well and good.  For temp-table backed browses - e.g. ADM2, I can write code to interrogate the SDO.

However, for static queries, QUERY:PREPARE-STRING returns ?

I've had a search through old forum posts, and can't find anything.  I don't want to change any legacy code - unless someone knows of a global ADM switch that will give me what I want...

NB.  Our ADM1 code can open the static query in a number of ways (using "freeform criteria"), so accessing the query definition preprocessors is not possible.

Any ideas?

Many thanks.

Guy

Posted by Frank Meulblok on 03-Mar-2017 09:52

But if you're not using DataServer, debug logging won't help.

ABL client logging does have the QryInfo logging type, but that doesn't log the query string for static OPEN QUERY statements either.

code:

define query stuff for customer.

log-manager:write-message("dynamic open").
query stuff:query-prepare("for each customer where custnum < 5 no-lock").
query stuff:query-open().

log-manager:write-message("static open").
open query stuff for each customer where custnum < 5 no-lock.

Gives following log entries for Dynamic query-prepare()/query-open():

... 2 4GL QRYINFO        Type: Dynamically Opened Query

... 2 4GL QRYINFO        PREPARE-STRING: for each customer where custnum < 5 no-lock

... 2 4GL QRYINFO        Prepared at Runtime

but static "open query" with same query string shows:

... 2 4GL QRYINFO        Type: Statically Opened Query

... 2 4GL QRYINFO        Prepared at Compile time

May be worth submitting an Idea for some way to expose the query string for statically opened queries as well.

But for short term, looks like there's no way to get what you want without somehow reworking your code. 

Replacing the static OPEN QUERY statements with dynamic prepare/open is probably a more elegant/more efficient approach, especially if you have to replace sets of OPEN QUERY statements. But depending on how many programs need to be reworked, it's still going to take a significant amount of time and effort.

All Replies

Posted by gus bjorklund on 03-Mar-2017 03:40

the r-code does not normally contain the source text of static queries so there is nothing available query-prepare:string to show.

Posted by Patrick Tingen on 03-Mar-2017 04:08

I tried to do something similar, but failed just like you. I think it is not possible. You might be able to do some analysis on the source code and get some info from that.

Posted by Stefan Drissen on 03-Mar-2017 07:30

When using a DataServer (SQL or Oracle) you can enable debug logging so that /translated/ queries as sent to the foreign database will be written to dataserv.lg.

Posted by Frank Meulblok on 03-Mar-2017 09:52

But if you're not using DataServer, debug logging won't help.

ABL client logging does have the QryInfo logging type, but that doesn't log the query string for static OPEN QUERY statements either.

code:

define query stuff for customer.

log-manager:write-message("dynamic open").
query stuff:query-prepare("for each customer where custnum < 5 no-lock").
query stuff:query-open().

log-manager:write-message("static open").
open query stuff for each customer where custnum < 5 no-lock.

Gives following log entries for Dynamic query-prepare()/query-open():

... 2 4GL QRYINFO        Type: Dynamically Opened Query

... 2 4GL QRYINFO        PREPARE-STRING: for each customer where custnum < 5 no-lock

... 2 4GL QRYINFO        Prepared at Runtime

but static "open query" with same query string shows:

... 2 4GL QRYINFO        Type: Statically Opened Query

... 2 4GL QRYINFO        Prepared at Compile time

May be worth submitting an Idea for some way to expose the query string for statically opened queries as well.

But for short term, looks like there's no way to get what you want without somehow reworking your code. 

Replacing the static OPEN QUERY statements with dynamic prepare/open is probably a more elegant/more efficient approach, especially if you have to replace sets of OPEN QUERY statements. But depending on how many programs need to be reworked, it's still going to take a significant amount of time and effort.

Posted by guymills on 09-Mar-2017 06:36

Thanks everyone for your responses - it's appreciated.

The static code in question is a mixture of ADM1 and "basic" progress GUI (written using AppBuilder).  I was looking for a quick/easy win, but there doesn't appear to be one (unfortunately).  Writing some auto-convert to use QUERY-PREPARE(), I think will be harder than just to look at the query in the source code.

I did quite like the idea of using the dataserver - however, it's not (currently) practical in our development environments.  We're currently investigating dataserver as it happens, but we're not at the point where we develop against it.  Getting the queries out and displaying them back to the "user" as a right click, I think would be a bit of a challenge too...

However, we do have some ADM2 functionality - and getting the query from SDO works a treat :-)

Guy

This thread is closed