Is possible execute a sentences progress from variable

Xavi_qsoft

New Member
Hello.

I would like konw if can execute sentences progress from a variable or fill-in.
For example:
I have a variable with the following value:
def var tmp as c no-undo.
assign tmp = "delete from customers".
You can run in any way?
The idea is to have a window with a fill-in where to run basic progress judgments (assuming that they know of course)

Thank you.
 

RealHeavyDude

Well-Known Member
Nope.

Everything you run on the 4GL engine is either pre-compiled or gets compiled on-the-fly. At that point in time all 4GL statements are resolved and must be syntactically correct. Therfore it is not possible to store 4GL statements on a variable and "execute" that variable at runtime.

What you can do is use dynamic buffers and queries to achieve limited similar functionality. What can be dynamic at runtime are the names of the database objects (tables and fields) and the query predicates.


Regards, RealHeavyDude.
 

mrobles

Member
Hi

You can do it but you need a development license.
In this example I use 2 programs

/* p1.p You enter the statements and call a program P2 */
DEF VAR inst AS CHAR NO-UNDO VIEW-AS EDITOR SIZE-CHARS 50 BY 4.
REPEAT.
UPDATE inst.
RUN p2.p inst.
END.

/* p2.p Execute the statments */
{1}
 

RealHeavyDude

Well-Known Member
Like mrobles pointed out, you need a development license to be able to do this. Having the development license you can compile on-the-fly whatever you put in a .p and run it - given the fact that it compiled successfully.


Regards, RealHeavyDude.
 

Xavi_qsoft

New Member
Thanks for the replies.

I saw you explain this method also on the knownledge base of progress and probe and really works:
For example:
OUTPUT TO "C: \ teste.p.

PUT UNFORMATTED
"MESSAGE" + "" "" + "hello" + "" "" + "VIEW-AS ALERT-BOX INFO BUTTONS OK." SKIP.

RUN "C: \ teste.p.
 

TomBascom

Curmudgeon
That method "works" but it has serious drawbacks. The main one being that the user needs a compiler license. If you are planning on deploying a solution like this in a typical end-user environment those licenses probably are not available (they are much more expensive). A second drawback is that it is "expensive" (in terms of machine resources and time) to write a temp file and compile it on the fly.
 

tamhas

ProgressTalk.com Sponsor
It is probably important to clarify what you actually want to accomplish. There is no simple, generic solution which does everything ... at least without writing code on the fly and compiling it ... but there are tools for dynamic queries and expression evaluation. You really wouldn't want a window which would allow someone to write "for each customer: delete customer. end." would you?
 

Xavi_qsoft

New Member
Excuse me if I did not explain better the subject or the confusion.
The truth that that window would not be put into production environments or final customers.
It would only useful for the development department in which there are approximately 400 boards, someone told me that "delete from table" was fast to a dynamic query and deletion.
I will look at progress if that's true or not, perhaps you can clarify this point, Is faster a "delete from table" or a dynamic query and delete records? that there are advantages of one over the other?

Thanks
 

tamhas

ProgressTalk.com Sponsor
Well, now ... totally different question.

What is "400 boards".

There is no magic superfast method to empty an entire table. Blocking the transaction to say 100 records at a time helps. Some have said SQL is faster, but basically it is degrees of the same thing.

There are possible tricks with type II storage area to drop the table and add it again.

And, there is the old trick of putting the table you want to clean regularly in its own database and simply deleting it and starting with a fresh empty copy.

In any case, if the real question is "how do I empty a database table quickly?", then you should ask that on the database forum.

And, of course, specify version of progress, size of table, frequency of delete, and a little something about why you want to delete your data.
 
Top