Easy to Create, Easy to Change - Easy to use!


New Sample - How to do multiple automated exports with ExecDQL()

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

New Sample - How to do multiple automated exports with ExecDQL()

Download Sample
I know we keep on harping on this but DQL is DQL, syntax wise that is true at least.

A lot of you approach ExecDQL with somewhat of a "trepidation". 

DataEase is extreemly powerful and it has been unnecessarily "restricted" in DFW. 

The engine that execute the DQL is the same that execute all other queries in DataEase so why should it be restrained by being in a stored document.

ExecDQL is basically executing a DQL script on the fly, which means you can execute any function/command in DataEase when you need it and you can generate the format in realtime.

In Tradtional dataease there is no way you can for instance delete all the records in any table on the fly without having created the DQL in DT beforehand as the only way you could do it was via the DQL command "delete records in tablename ."

Now you can simply run it as execdql

On a button:
ExecDQL("delete records in data-entry field1 .", Myfield) -- myfield is a field in the form but could be GetVar("MyFieldValue") or anything else you are allowed in dataease programming in DT as well as RT.

in a DQL:

retval := ExecDQL(concat("delete records in ",Myvar),".") .

etc.

Everything in the future of DataEase will be oriented around execution of scripts (text: DQL,HTML,JavaScript) etc. Nothing will be compiled or stored as Binary files.

ExecDQL is just a small beginning where the next step is DataEase Server/WebForms etc.

Anyhow, back to the current problem.

There is no wizzardry to using ExecDQL for exporting.

In "basics" it is like DFD DQL the only difference is how you present it with the Script and the Format etc.

In MemoExecDQl you have to serve the Function with a Memo that contain the DQL Script and a memo that contain the output formatting.

The DQL is simply a normal DQL and the layout is like a DFD layout. It is completely FREE as long as you follow the rules of levels (grouping etc).

The DQL is not case sensitive but the Layout tags are so if you use "Customer" in list records you need to use [{Customer}] in layout too.

If you don't include a layout in the function it will use the standard DataEase export format which happens to be exactly as the one we have created. You can however create any export format or any other output you like.

You can of course also export to a PDF/Output to a Memo or to a web page.

Our DQL that fire the 3 (exactly similar but that is just out of lazyness) DQLs is the one below.

define "retval" text .

define "starttime" time .

starttime := current time.

-- this DQL could of course also have just been a ExecDQL that would have made it even sleaker but we wanted to draw the connection back to tradtional DQL which is why we fire it from here.

Message concat(data-entry directory,"\7.txt") .

retval := MemoExecDQL(any ExecDQLStore with DQL Number = 007 DQL,"","","","",concat(data-entry directory,"\7.txt"),any ExecDQLStore with DQL Number = 007 Layout) .

Message concat(data-entry directory,"\8.txt") .

retval := MemoExecDQL(any ExecDQLStore with DQL Number = 008 DQL,"","","","",concat(data-entry directory,"\8.txt"),any ExecDQLStore with DQL Number = 008 Layout) .

Message concat(data-entry directory,"\9.txt") .

retval := MemoExecDQL(any ExecDQLStore with DQL Number = 009 DQL,"","","","",concat(data-entry directory,"\9.txt"),any ExecDQLStore with DQL Number = 009 Layout) .

message concat("Exported via 3 different ExecDQL's all data in Addressbook. Total time: ",current time-starttime, "second(s).") window .

In the sample we have showcased how you can call the DQL's from a traditional DQL, LabelExecDQL and MemoExecDQL.

We also show you how you can read the files back into a Memo with MemoReadFromFile().


Written by DataEase 02/07/17 at 16:54:26 Dataease [{8}]FIVE