Simplicty and flexibility!


LE9-How to call ExecDQL directly from code

Started by DataEase
You will need to Sign In to be able to comment on the Blog!

LE9-How to call ExecDQL directly from code

ExecDQL started small and is now all-encompassing. What started as a way to execute a DQL for processing with no output now powers websites and has taken on a life on its own with self-permutation etc.

More of that in a different location, here we will talk about how you can make it easier to use ExecDQL directly without having to load the code into a Memo or write it into a label etc.

Over the years since ExecDQL was introduced we have all made different forms to store the DQL and you might have seen that there is now a form called $$DQLStore$$ in new applications.

This $$DQLStore$$ conforms to the new features of calling/loading ExecDQL with @Name and #number. This is done as it is a little cumbersome to write the entire DQL into a derivation, or having to load the DQL

with Lookup/AnyLookup etc.

The syntax is simple:

The setting for execdql @name and #id

DqlNameField - Gives the field name used to lookup the @name used in execdql. The field have to be a text field. Default is "DQLName".

DqlIDField - Gives the name of the field that is used to lookup #id in execdql. The field have to be a numeric field. Default is "DQLId".

DqlCodeField - Gives the name of the memo field that is used for dql body in execdql using either @name or #id for looking it up. Default is "DQLScript".

DqlBodyField - Gives the name of the memo field that is used for dql code in execdql using either @name or #id for looking it up. Default is "DQLBody".

DqlTableName -Gives the execdql table name for @name and #number calling execdql. Default is "$$DQLStore$$".

All of this has to be set in the [EXECDQL] section unless used in server as you can have one for each prefix set and set it direct into this section instead.

You only need to set the settings that deviate from the defaults above.

[EXECDQL}

DQLNameField=ThisIsWhatICallMyDQLs

DQLIDField=MyNumberInSequene

DQLScriptField=MyScrips

DQLBodyField=MyBodyDefinitions

DQLTableName=MyDQLStoreInMyApp

When this is set you can simply call your DQL's directly with @ and #

ExecDQL("@ListNames","","","","","","@ListNames") -- this will run DQL ListNames and format it according to the Body field in that definition. If you want to use a different body definition you can use one from a different DQL.

ExecDQL("@ListNames","","","","","","@ListNamesAltBody")

If you want to just run a DQL with no data-entry intput or formatting.

ExecDQL("@MyProcessing")

PS! Remember that ExecDQL is a function so the result of the DQL with formatting is returned from the function.

Define "myfomattedresult" memo.

myformattedresult := ExecDQL("@ListNames","","","","","","@ListNames") .

Now the entire produced output from the DQL will be in the memo variable and can be used for whatever you want it to be.

ANy DQL without a body will return the list records as a ~ separated file, but if you return only one value it will be the value only

try this in a derivation: alert(execdql('List records "Jonny" .'))


Written by DataEase 08/11/24 at 15:16:23 LegEasy 9 Developer

Re:LE9-How to call ExecDQL directly from code

excellent.will try. thx.

Glory to DataEase Team!


Written by Ihor Zakharchenko 08/11/24 at 15:35:11 LegEasy 9 Developer
DG3_BlogList