main sql in a grid

Hi, I am a new scriptcase user.

I have a question:

Is it possible to have a dinamic main query in a grid?

I mean:

I need to use the same grid but sometime the command select of the main sql contains the WHERE clause and other time not.

It would be a code waste to copy the same grid with two different name and so little difference.

Somebody may help me?

Thank you for your assistance.

Re: main sql in a grid

From the web help:

ScriptCase Macro:

sc_select_where(add)

Is possible, during grid execution time to add a field/condition to the search WHERE clause.

Ex. 1: It adds the contente between the quotes (") in the grids select.
if (empty({sc_where_current}))
{
sc_select_where(add) = “where campoX > [global]”;
}
else
{
sc_select_where(add) = “AND campoX > [global_variable]”;
}

Note: This command must be in the context of “process before the select”.

Macro Scope

Grid Report PDF
onScriptInit onScriptInit

Re: main sql in a grid

Perfect!!
Thank you very much.
Your tip was of little of help to me.