Simplicty and flexibility!


Routine in the same DQL


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

Routine in the same DQL

Hi Dataease, there's a way to insert a "subroutine" in the same DQL without creating a second DQL for this. I need simply call a subroutine many times inside the same DQL avoiding to use "Run procedure XXXXX" several times. Thanks. 


Written by Marco Marchesi 23/11/16 at 09:14:58 Dataease [{8}]FIVE

Re:Routine in the same DQL

Definitely.

It is called ExecDQL and you can execute it directly or you can save it in a table and look it up.

retval := ExecDQL("delete records in MyTable with RecordID=data-entry field1 .",MyIdField) .

retval := MemoExecDQL(any DqlStore with DQLID=003 DQL,MyFieldID etc ...

Thinking of DQL as static documents is long gone in DataEase 8. DQL is dynamic and you can even generate it in a DQL and then execute it on the fly.


Written by DataEase 23/11/16 at 15:59:42 Dataease [{8}]FIVE

Re:Re:Routine in the same DQL

Thanks. I already know ExecDql and MemoExecDQL function, but my question is if I can create a subroutine inside the same DQL and execute it several times. Please look at your example below :

define "numero" number .
define "risultato" number .
assign numero := 10 .

/* This procedure takes a number and returns its square */

procedure Number SqByVal(Number x)

return x*x .

end.

assign Risultato := SqByVal(Numero) .
message risultato window .

The goal is execute the "procedure takes a number and return its square" many times for different number avoiding to execute it via "EXECDQL" ,"Memoexecdql" , run procedure etc..

For example in my subroutine there is a simply procedure that write a record on a table using the global variable passed by the main procedure. Here the DQL:

define global "Carrier" text 25 .
define global "Part" text 2 .
define global "tipology" text 20 .
define global "Field" text 120 .
define global "Rule" text 10 .
define global "Rule_Description" text 80 .
define global "Bond_Id" text 85 .


enter a record in TBEZBondExposureSII_DataQuality
Carrier := global Carrier ;
FldName := global Field ;
FldType := any TBEZDataQualityField FldType ;
FldLength := any TBEZDataQualityField FldLength ;
Rule := global Rule ;
Rule_Description := global Rule_Description ;
Part := global Part ;
Tipology := global Tipology ;
Bond id := global Bond_Id .

I want to execute it inside the same DQL.

Regards


Written by Marco Marchesi 24/11/16 at 08:00:11 Dataease [{8}]FIVE
DG3_ForumList