sql statement and validations

Hi I’m new in scriptcase and Ihave a problem that I don’t know how to solve.

I need to make a grid with a filter, in the filter I have to put one code and a range of dates and with that, I could generate the grid. So far so good until now

But I need some validations for the recordset and I don’t know how and where to put the code to do this

I have 2 tables:

tbl_institutions
cod_inst


tbl_movs
PK
nr_inter
Cod_inst
type
date

(there are many records with the same nr_inter and cod_inst but different date and type)

So, for example in filter cod_inst = 20 range between 2011/04/01 and 2011/04/30

In case have one record for a nr_inter that comply the two conditions

Nr_inter 1
Cod_inst 20
type 2
date 2011/04/06
days 24 (calculated field: difference between the date on recor and the last date of the range)

In case have more than one record

nr_inter 2
Cod_inst 20
type 2
date 2011/04/08
days 4 (calculated field: difference between the date on record and the date of the next record)

nr_inter 2
Cod_inst 20
type 3
date 2011/04/12
days 18 (calculated field: difference between the date on record and the last date of the range)

In case have no record that comply but the type has different to 1 and date minor of range

nr_inter 2
Cod_inst 20
type 3
date 2011/02/09
days 30 (calculated field: the total of days in the range)

So, How could I do that?

Thanks in advance.

Quatrero

Re: sql statement and validations

I am not sure I understand …

Are you setting up a grid with a search at the top at load time, or are you setting up a search app.

If you wanted to load a grid with not built in grid, but need validation, then perhaps load a control form first that prompts the user for valid info and they use those entries to load the grid
using sc_link to send the parameter to the grid SQL.

Regards,
Scott.

Re: sql statement and validations

Thanks for your answer.

Really it’s the same, I need an app in wich the user put the cod_inst (may be with a link to search the correct one), and a range of dates.

Then, with this parameters I need to validate with the conditions that I posted.

But I don’t know how make this validations. Where I put the code for validations? And, Exists an article where I can read how to write the code in scriptcase? I mean How to declare and use variables, loops, etc.

Re: sql statement and validations

If you create a control form and add the fields, you can validate the field runtime using Javascript, or you can use onValidate to process things on submit. On success, call the grid using sc_link with the valid parameters and have the grid accept the parameters to view the filtered data.

JS: onLoad/onSubmit, or JS: fieldname: onChange/onBlur, etc
document.F1.your_input_field.value == <correct value>

or

php code in the onValidate event.

Regards,
Scott.

Re: sql statement and validations

Thanks a lot, I will try.