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


ExecDQL


Started by Rainer
Search
You will need to Sign In to be able to add or comment on the forum!

ExecDQL

ExecDQL("for AUFTRAG with Belegnr=data-entry field1 ; modify records Bestellers:= "RRR" .", "Belegnr","","","","" )

what is wrong? I want to update the aktual record.

second question: I store my DQL's in a table "DQL" with DQLnr and DQLtext (memofield). How can I call it

FileExecDQL("lookup DQL with DQLnr = 0001; DQLtext", "Data-entfy field1" ,"","";"";"")?

please give my an real example

Written by Rainer 13/09/14 at 19:39:41 Dataease [{8}]FIVE

Re:ExecDQL

Hello Rainer.  

It is nice to see that sometimes we are "ahead" of the user ;-)

Your problem here is that you are not seeing the forest for all the threes...

The reason we very quickly implemented MemoExecDQL() followed by LabelExecDQL() is the problem ExecDQL() had with the syntax of DQL.

" is a protected character in both Derivation and DQL/OML so when you try to combine the two you get problems.

ExecDQL("for AUFTRAG with Belegnr=data-entry field1 ; modify records Bestellers:= "RRR" .", "Belegnr","","","","" )

If you should do this in traditional DE8 you would have to do this:

ExecDQL(concat("for AUFTRAG with Belegnr=data-entry field1 ; modify records Bestellers:=",chr(34),"RRR",chr(34),"."),"","","","" ) 

So now you see why we quickly made MemoExecDQL() so you could type in the DQL in one Form/Memo and the simply look it up in a Virtual Field in the form via a traditional Lookup (relatinonship) and then execute it.

However, as things progressed we realised it was high time that DataEase would allow developers to write reserved character "inline" so we implemented Escape Characters.

/'=" /CR=New Line and /TB =TAB.

So now you can simply write:

ExecDQL("for AUFTRAG with Belegnr=data-entry field1 ; modify records Bestellers:= /'RRR/' .", "Belegnr","","","","" )

And everything should be hokey dory. 

We use MemoExecDQL exstensively in all our samples so simply disect the CRM app and you will see it used almost everywhere. OML/Virtual Fields etc.

http://www.dataease.com/dg3_HelpView/?PageID=10339&field1=*ExecDQL*

Written by DataEase Tech Sup 14/09/14 at 09:16:12 Dataease [{8}]FIVE

Re:Re:ExecDQL

thank's. I do not get a "error"now, but it does not do the update on the actual record?

ExecDQL("for AUFTRAG with Belegnr=data-entry field1 ; modify records Bestellers:= /'RRR/' .", "Belegnr","","","","" )

I tried also the memoexecdql

excecute funktion

MemoExecDQL("DQL","Belegnr","","","","", )

DQLstore

modify records in AUFTRAG with Belegnr = data-entry field1;

Bestellers:= "rainer" .

what's wrong?

Written by Rainer 15/09/14 at 06:56:08 Dataease [{8}]FIVE

Re:Re:Re:ExecDQL

"Belegnr"

Now you send the string containing the word Belegnr to your DQL, When you reference a table or a column (field) you should Never use "".

Anythng in "" will be passed as is to the function.

So the correct derivation is:

ExecDQL("for AUFTRAG with Belegnr=data-entry field1 ; modify records Bestellers:= /'RRR/' .", Belegnr,"","","","" )

Written by DataEase 15/09/14 at 11:35:39 Dataease [{8}]FIVE

Re:Re:Re:Re:ExecDQL

ok the execdql works I got it.

but

I tried also the memoexecdql

excecute funktion:

MemoExecDQL(DQL,Belegnr,"","","","")

DQLstore

modify records in AUFTRAG with Belegnr = data-entry field1; Bestellers:= "rainer" .

I get an error. Can I  not refer directly to the data-entry field1 as I did?

Written by Rainer 15/09/14 at 21:13:35 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:ExecDQL

There is one thing one need to do in DE8 and that is to take a step back.

Almost intentionally we do things "across" the established truths. With Functions like MoveObject, SetClass, MemoClass etc. we basically challenege the artificial limitations cemented into DE over 20 years.

Due to the "idea" that DE is an interactive tool where the users are "co-programmers" a lot of artificial limitations has been introduced into the product to limit the harm they could make.

In 2014 we just have to accept that Users aren't programmers and to allow them to change a system in runtime is borderline madness.

So instead of allowing the user to infringe on the developers turf, we move it the other way and allow the Developer to infringe on the Users turf i.e. allow the application to "morph" in Runtime.

Up to 8.0 there was no way you could change the programming of you application in Runtime, but this ha now all changed.

ExecDQL is an interpretive way of running DQL. In the basic function (ExecDQL) you can write the code straight into the derivation, but you can also store it in a text field and simply execute the code on the fly. So if you had a table with 1000 records and a different stored DQL in each record with the button action in the record like this:

ExecDQL(MyExecDQLField,MyDataEntryField1,MyDataEntryField2,MyDataEntryField3,MyDataEntryField4,MyExportFile)

You would be able to run a copletely different DQL every time you went to the next record and hit the button.

In DE there is a limitation that a function can only return 255 characters and a parameter in a function can only be 255 character so to write bigger DQLs into a derivation is awkward so we need to store them somewhere. Where better than in a DataEase table.

We normally call this table ExecDQLStore, but it could be called Gunther as it is just a DataEase table with a memo field where we can save and edit a DQL on the fly.

So now I have sorted out the storing, I need to sort out the using.

If you want to use data stored in another table in DataEase you need to use Lookup.

So you need to have a relational constraint to look up the correct DQL i.e. key and then you need a virtual field to look it up into with the derivation like this: lookup execdqlstore DQL (or lookup Guenther Script etc).

When the script is read into the virtual field you can simply execute it on a button or another derived virtual field etc.

You need to do this this way due to the limitations of Relationships (pre-defined) in Forms but to be honest you can do this too if you combine execDQL and MemoExecDQL... ;-)

ExecDQL("define /'retval/' text. retval := MemoExecDQL(any ExecDQLStore with DQLNr=14 DQL,Data-entry field1, Data-Entry field2, Data-entry Field3, Data-entry field4,/'/').","","","","","") .

So simply but. MemoExecDQL() execute the DQL saved/viewed in a Memo field so you simply need to follow normal DE rules for populating the Memo field and then execute the script that is then stored in it.

You think that there is some hidden wizzardry here but there isn't. If you are to exectute a DQL stored in a memo in a different table, you need to read that Memo into your corruent form (one way or the other) via normal relational rules.

Written by DataEase Tech Sup 16/09/14 at 08:18:15 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:ExecDQL

I understand all that. That is not my problem. I call the DQL from  my "DQLstore" with the viruell MemoField/lookup etc.:

modify records in AUFTRAG with Belegnr = data-entry field1; Bestellers:= "rainer" .

and I have the Button "execute derivation/funktion" in the Form "AUFTRAG"

MemoExecDQL(DQL,Belegnr,"","","","").

AUFTRAG is the Tabel/Form I am in.

Belegnr ist the Field/unique.

please just tell me what  is wrong.

Written by Rainer 16/09/14 at 10:11:58 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:Re:ExecDQL

1. Test the DQL in the form where you type it in first (ExecDQLStore). If it works there, then the problem is your lookup.
2. Check that the DQL is looked up in the virtual Memo field in Auftrag. If you can see it there then it should work on your button. You can make the Virtual Memo field editable so you can scroll it etc.

We are flattered when you guys think we can read minds, but we can't. The fact that something doesn't work when it should is not a good enough explaination for us to figure it out. We can give examples and general advice, but if there is something that doesn't work when it should we need a sample that showcase it.

The sample can be uploaded here by simply choosing image and drag-drop it onto here or it can be emailed to techsup@dataease.com

Written by DataEase Tech Sup 16/09/14 at 12:27:53 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:Re:Re:ExecDQL

Hi again Rainer and thanks for the images.

Again everything looks OK, but I see that you are running a DQL to modify the PRISM values (i.e. the same record you are viewing). This is a bad idea and depending on your Locking model "illegal".

If you have full locking you would most likely just not get anything, and if you have Opportunistic you would get that the record has already changed if you tried to save it from the form.

Using ExecDQL has its responsibilities as you have a lot of freedom, but you still need to follow the basic rules of DataEase.


ExecDQL has the context of the form from where it is called so you can simply use Form properties to manipulate it rather going via PRISM if it is the same form you want to manipulate.

The DQL you are using here is very simple so might not be a good sample for here as the way I would do this wouldn't even be with a DQL, I would simply use SetValue("Bestsellers","Rainer")

As a DQL that would be.

define "retval" text .
retval := SetValue("Bestsellers","Rainer") . -- Beware that GUI functions use the object name and not the column name.

So the general rule is.

If you are going to use ExecDQL to manipulate the current form, use GUI functons like SetValue()/GetValue() -- You can pick a value out of a field from an ExecDQL script. SetState()/SetValue()/SetStyle().

You can do any calculation, lookup values etc in a DQL and then simply push the value back in the field with SetValue().

At the end of your DQL you can also use Retval := RecordSave(). and you save the data in the form. 
You can also use DocumentClose()+DocumentOpen("AnotherForm") etc.


An ExecDQL is both OML and DQL in one just in DQL guise. It will be able to do a big transaction and the push the results back into the current form, or open another form where you do the report etc.

It can do everything that DataEase can do, so id anyone think that ExecDQL is the little brother of "old style" DQL they are very much mistaken.

Written by DataEase Tech Sup 18/09/14 at 11:44:03 Dataease [{8}]FIVE