[Mars][HowTo] insert multi records in SQL.insert statement [message #1724116] |
Sun, 21 February 2016 09:47 |
barust Mising name Messages: 57 Registered: February 2014 |
Member |
|
|
For example,
I need to add to the table of the year and months, in my case it is 2016 and 12 months.
Naturally year repeated 12 times, but how to do it.
Here is my solution:
I have a table SCHEDULE with columns: PODR_ID, S_YEAR, S_MONTH.
On #Client/Forms I created form ScheduleForm with PodrNr and Year fields.
In #Server/Services/ScheduleService the solution is as follows:
@Override
public ScheduleFormData create(ScheduleFormData formData) throws ProcessingException {
if (!ACCESS.check(new CreateSchedulePermission())) {
throw new VetoException(TEXTS.get("AuthorizationFailed"));
}
for (int k = 1; k <= 12; k++) {
SQL.insert(""
+ "INSERT "
+ "INTO SCHEDULE (PODR_ID, S_YEAR, S_MONTH) "
+ "VALUES (:podrNr, :year, :k)"
, new NVPair("k", k), formData);
}
return formData;
}
Perhaps this is trivial, but I think somebody is handy.
I have a question, is there any other decision of this problem with SQL.insert?
Barust R
-
Attachment: Table.png
(Size: 16.29KB, Downloaded 138 times)
[Updated on: Sun, 21 February 2016 09:49] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03909 seconds