"dynamic query"

Anybody know a way to do a query in a manner that it can receive parameters such as tables, search conditions, order conditions etc, and then construct a query in execution time ?
I try with copycode but it can’t receive variables as parameter. Also try run a program using &global-variables but I lose control of execution.
some ideas please ?
thanks.

Try this…

  • Specify output destination for one of your printers as ‘SOURCE’, for example - DEFINE PRINTER (1) OUTPUT ‘SOURCE’

  • Generate your “dynamic query” by WRITE (1) … this will write code into the source area

  • Make sure that the object type is “program” (if not - set it up as the “program”)

  • then simply execure that code via STACK TOP COMMAND ‘RUN’

It works for me…

thank Nilolai, this works, but, to execute the code i need to stop the dialog from which i make the “dynamic query”.

Don’t you know a way to execute this code without exit from the dialog that make the “dynamic query” ?

Have you tried launching an async task instead of using STACK? See library SYSEXPT . There are 2 examples of interest … one to start the async task and one to have the “parent” program wait for it.

Why not create a CLASS that does the create/run of the program, instantiate it and call the method to create and execute the query? This will not disturb your program flow.

Just an idea…

billiboy

Hi, there is natural sintax FLEXIBLE SQL, search in Natural help, you must use << >> and Text Variables for construct your query.

Spect this be useful,

Adolfo Gal

easy task…did this last century when no middleware was available and gave a presentation about it in the SAG Group NW region.

got to use Natural virtual editor, then just dynamically write the natural program once finished one could stow it and executed or simple execute it.

one could further refine it by using Predict and reading the ddm to code the data block…

what i did back then was to take a SQL statement, separated it and based on the columns (if the * was used then I picked all of the fields) wrote the corresponding Adabas I/O statements.

Lastly, to return data, I simply took what came form the db and XML tagged it.

it’ll take some work but it’s doable.

btw, to stop the dialog enter STOP, this will stop execution and process the next STACK COMMAND

Check if this can help:

http://tech.forums.softwareag.com/viewtopic.php?p=67377&highlight=&sid=e1eac9e3b497447f25d26c22085117c7#67377