# "dynamic query"

**URL:** <https://techcommunity.softwareag.com/t/dynamic-query/60445>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-News-and-General-Topics\
**Created:** [January 18, 2006, 11:58pm UTC](https://techcommunity.softwareag.com/t/dynamic-query/60445 "2006-01-18T23:58:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![fede](https://avatars.discourse-cdn.com/v4/letter/f/9fc348/32.png) [@fede](https://techcommunity.softwareag.com/u/fede)\
**Post date:** [January 18, 2006, 11:58pm UTC](https://techcommunity.softwareag.com/t/dynamic-query/60445/1 "2006-01-18T23:58:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Nikolai](https://avatars.discourse-cdn.com/v4/letter/n/8491ac/32.png) [@Nikolai](https://techcommunity.softwareag.com/u/Nikolai)\
**Post date:** [January 20, 2006, 12:54pm UTC](https://techcommunity.softwareag.com/t/dynamic-query/60445/2 "2006-01-20T12:54:25Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![fede](https://avatars.discourse-cdn.com/v4/letter/f/9fc348/32.png) [@fede](https://techcommunity.softwareag.com/u/fede)\
**Post date:** [January 23, 2006, 4:27pm UTC](https://techcommunity.softwareag.com/t/dynamic-query/60445/3 "2006-01-23T16:27:41Z")

</div>

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” ?

---

<div class="post-metadata">

**Author:** ![Darrell](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@Darrell](https://techcommunity.softwareag.com/u/Darrell)\
**Post date:** [February 1, 2006, 2:15am UTC](https://techcommunity.softwareag.com/t/dynamic-query/60445/4 "2006-02-01T02:15:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Peter\_Pag](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@Peter\_Pag](https://techcommunity.softwareag.com/u/Peter_Pag)\
**Post date:** [February 1, 2006, 1:34pm UTC](https://techcommunity.softwareag.com/t/dynamic-query/60445/5 "2006-02-01T13:34:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chofo](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/chofo/32/119_2.png) [@Chofo](https://techcommunity.softwareag.com/u/Chofo)\
**Post date:** [February 23, 2006, 6:51am UTC](https://techcommunity.softwareag.com/t/dynamic-query/60445/6 "2006-02-23T06:51:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dario](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@Dario](https://techcommunity.softwareag.com/u/Dario)\
**Post date:** [February 8, 2011, 10:34pm UTC](https://techcommunity.softwareag.com/t/dynamic-query/60445/7 "2011-02-08T22:34:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dario](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@Dario](https://techcommunity.softwareag.com/u/Dario)\
**Post date:** [February 8, 2011, 10:38pm UTC](https://techcommunity.softwareag.com/t/dynamic-query/60445/8 "2011-02-08T22:38:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ats](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Ats](https://techcommunity.softwareag.com/u/Ats)\
**Post date:** [February 9, 2011, 12:06pm UTC](https://techcommunity.softwareag.com/t/dynamic-query/60445/9 "2011-02-09T12:06:11Z")

</div>

Check if this can help:

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:40pm UTC](https://techcommunity.softwareag.com/t/dynamic-query/60445/10 "2021-04-02T14:40:24Z")

</div>


