I have a table with a composite primary key ( two columns ),
How should I loadrecords with a composite primary key,
I tried:
controller.loadrecords('select ibcod,ref from bancos_tx');
but the dataset is empty, with one all works good.
Thanks Armin
Try something like this:
controller.loadrecords('select ibcod,ref from bancos_tx where xxx = ?',['test']);
If you want to load all records you can simply use controller.loadAllRecords().
Whops, submitted too fast…
Have a look at the sample code for loadRecords():
//5) to load records in to the form based on a query (also known as 'Form by query')
//forms.credits.controller.loadRecords(sqlstring,parameters);
//limitations/requirements for sqlstring are:
//-must start with 'select'
//-the selected columns must be the (Servoy Form) table primary key columns (alphabetically ordered like 'select a_id, b_id,c_id ...')
//-can contain '?' which are replaced with values from the array supplied to parameters argument
// if the sqlstring contains an 'order by' clause, the records will be sorted accordingly and additional constraints apply:
//-must contain 'from' keyword
//-the 'from' must be a comma separated list of table names
//-must at least select from the table used in Servoy Form
//-cannot contain 'group by', 'having' or 'union'
//-all columns must be fully qualified like 'orders.order_id'