D
dbeavon
Guest
That link to the chapter about dynamic queries is very helpful. Thanks. >> How do I introduce arguments to my query predicates? What I'm wondering is how to use an argument/variable, and change it in a loop, and ensure that the query will respect it's value. Ie. if I have iCustNum and I have a query that I prepared ("FOR EACH customer WHERE CustNum = iCustNum") then the query should be prepared/compiled once, and executed repeatedly for different customers by changing the value of iCustNum. But I haven't been able to accomplish anything along these lines. It does not seem possible to have a dynamic query that uses an argument/variable. The only way I've been able to get a different customer is to change the literals in the character string that is sent to QUERY-PREPARE. IE. you have to switch that foreach and instead of using iCustNum as an argument, you have to bake in the current *value* : "FOR EACH customer WHERE CustNum = " + STRING(iCustNum). It seems unnatural to repeatedly compile a piece of code that isn't really changing. Only the argument to it is changing. In a sense it seems to me that in some regards the "dynamic" query is even less dynamic than a statically compiled program that references iCustNum from a locally scoped variable. Am I missing something?
Continue reading...
Continue reading...