Need to assign the preprocessor value at runtime

karikalanr

New Member
Hi everyone,

I have a include file with below statement,

OPEN QUERY {&query-file} BY {&sort-by-1}.

In called program {&query-file} value will be assigned based on the runtime navigation. As preprocessor value has been assigned in the compile time itself, I could not meet the runtime requirements. Just like to avoid dynamic queries in the Open Query statement, I am preferring to use preprocessor tags.

I appreciate, If any work around to achieve this scenario.

Thanks,
Karikalan
 
You can't! Preprocessors are evaluated at compile-time, end of story.

If you're building a query clause based on user input, dynamic is the way to go. Why wouldn't you want to use dynamic queries? This is what they're there for.

The only way you can use preprocessors at run-time is if you compile on-the-fly, but for that you need the licence to suit, and it will be slow to run.
 
Allright.,

Just I am thinking to use any other simplest way to implement it. subsequently I have got an idea to pass the value at runtime by avoiding pre-processor.

{start_search.i "q-browse1 FOR EACH student WHERE {&where}"}

Inside the include file, will compose the query as,

OPEN QUERY {1} BY {&sort-by-1}.

Its works well, Though, I need to assign the value to variable to pass as a parameter to include file.
v_qclause = "q-browse1 FOR EACH student WHERE {&where}"
For ex,

{start_search.i v_qclause}

- This has been bringing the issue. Inside the include file getting null value for the variable v_qclause. Any workaround please....

 
Again as a pre-processor, &v_incl_ipt expects the value at compile time. Ok. Seems to be no other way except dynamic queries.
 
For ex,

{start_search.i v_qclause}

- This has been bringing the issue. Inside the include file getting null value for the variable v_qclause. Any workaround please....


If you want to use a where clause in a variable (and hence, configure a query at run-time) then it's compile-on-the-fly or dynamic queries only. No way around it - preprocessors are evaluated at compile-time and that's that!

Dynamic queries are great! If you need any help with the code, just post away.
 
Many thanks Andrew,

I had finished that work using dynamic query finally. Since, its require to determine the sort order value at runtime, we are bound to use dynamic query. Thanks for your support.

Cheers,
Karikalan
 
Back
Top