Support Topics Documentation Slack YouTube Blog

Update the whole table

I am using the “Updating Multiple Objects” API which states

This API updates multiple objects in a data table with a single request. Consider the following example, it demonstrates an API call which updates all objects in the Person data table where the value of the property age is greater than 20 . As a result of the request, all updated objects will have the contactType property set to "personal" :

I am doing the exact thing but the outcome is different

I have 3 rows in my table and based on some logic I wanna change the value for 1 row by defining if this is equal to this and that is equal to that, but when I use it in my app or call the API then the value of that box changes and it changed all the boxes of all rows

below is the image and in that ownerId is same but the jobNumber is different so why my all three rows
get

affected by this… Any help is appreciated
> String whereClause = “ownerId = '” + teacherOwnerId + “’ && jobNumber = '” +
teacherJobNumbers + "’ ";
> DataQueryBuilder queryBuilder1 = DataQueryBuilder.create();

                        queryBuilder1.setPageSize(31).setOffset(0);
                        queryBuilder1.setWhereClause(whereClause);

                        Map<String, Object> changes = new HashMap<>();
                        changes.put("teacherVsStudentLinkage", true);
                        changes.put("applicationStatus" , Parttime_Report_Sent_Student_Teacher.APPROVED); //approved status
                        changes.put("studentComplaint" , "NO COMPLAINT"); // no complaint
                        changes.put("PDFreportDownloadURL" , ""); // empty the url field
                        Backendless.Data.of(FullTimeJobs.class).update(whereClause, changes, new AsyncCallback<Integer>() {
                            @Override
                            public void handleResponse(Integer response) {


                                approved.setText(operationComplete);
                                approved.setBackground(ContextCompat.getDrawable(ShowTeacherDetail.this , R.drawable.one_vs_three_white));
                                approved.setTextColor(ContextCompat.getColor(ShowTeacherDetail.this , R.color.userInputColor));

                                new CountDownTimer(2000, 500) {
                                    @Override
                                    public void onTick(long millisUntilFinished) {

                                    }

                                    @Override
                                    public void onFinish() {


                                        hideViews();
                                        noRecordFound.setText(thankYou);
                                        noRecordFound.setVisibility(View.VISIBLE);

                                        new CountDownTimer(2000, 500) {
                                            @Override
                                            public void onTick(long millisUntilFinished) {

                                            }

                                            @Override
                                            public void onFinish() {
                                                finish();
                                            }
                                        }.start();


                                    }
                                }.start();

                            }

                            @Override
                            public void handleFault(BackendlessFault fault) {

                                approved.setText(operationFailed);
                                approved.setEnabled(false);
                                approved.setBackground(ContextCompat.getDrawable(ShowTeacherDetail.this , R.drawable.one_vs_three_white));
                                approved.setTextColor(ContextCompat.getColor(ShowTeacherDetail.this , R.color.userInputColor));

                                new CountDownTimer(2000, 500) {
                                    @Override
                                    public void onTick(long millisUntilFinished) {

                                    }

                                    @Override
                                    public void onFinish() {

                                        approved.setEnabled(true);


                                        approved.setText(approvedx);


                                    }
                                }.start();

                            }
                        });

Try this one:
String ownerId = "' + teacherOwnerId + "' and jobNumber = '" +teacherJobNumbers + "'";

I also recommend to test your where clause on select requests beforehand.

Thanks for the point out putting and instead of && solved my problem but i did not get why && not working ??

Hi Saad,

In whereClause used our own syntax and it’s oriented to simplify syntax. Combination “&&” comes from programming, when “and” is more understandable and convenient for most people. So “&&” is not declared operator there and that’s the reason why it doesn’t work.

Regards, Vlad

In addition to what @vladimir-upirov said, I believe the where clause grammar allows only for AND and OR: https://en.wikipedia.org/wiki/Where_(SQL)