I
I
Ilya Brazhnikov2017-02-17 15:58:06
1C
Ilya Brazhnikov, 2017-02-17 15:58:06

How to correctly create a query to find the last actual record in registers in 8.3?

Records of the type are stored in the information registers:
Dimension Bus (Directory element)
Dimension Serial number (String)
Resource: MovementType (Enumeration)
Resource Mounted Mileage (Number)
Resource Total Mileage (Number), etc.
Task Find the last entry in the register for the pair Name + Serial number.
Searching in a slice of recent does not return a result if the entry with the pair is not the last.
How to make a request correctly and is a solution possible with such initial conditions?
Request text:

Запрос = Новый Запрос;
  Запрос.Текст = 
    "ВЫБРАТЬ
    |	ДвиженияШинСрезПоследних.ТипДвижения,
    |	ДвиженияШинСрезПоследних.Автомобиль,
    |	ДвиженияШинСрезПоследних.ОбщийПробегШины,
    |	ДвиженияШинСрезПоследних.Ось,
    |	ДвиженияШинСрезПоследних.ПробегАвтоПриУстановке,
    |	ДвиженияШинСрезПоследних.ТекущийПробегШины
    |ИЗ
    |	РегистрСведений.ДвиженияШин.СрезПоследних КАК ДвиженияШинСрезПоследних
    |ГДЕ
    |	ДвиженияШинСрезПоследних.Шина = &Шина
    |	И ДвиженияШинСрезПоследних.СерийныйНомер = &СерийныйНомер";
  
  Запрос.УстановитьПараметр("СерийныйНомер", СерийныйНомер);
  Запрос.УстановитьПараметр("Шина", Шина);

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Kinash, 2017-02-17
@Ilyabr

Not a question, but a terrible mess.
1) >> Find the last entry in the register for the Name and Dimension pair.
The name is the dimension. Is it only necessary to look for a value for a specific Name? Or is it for a full pair Name + Series?
2) >>Searching in the latest slice does not return a result if the entry with the pair is not the last.
What is written contradicts the very idea of ​​cutting off the latter. Or you do not need the latest data - here check that you would pass the correct date to the parameters of the virtual table. Or you need data for other sets of dimensions - here check the selection in the parameters of the virtual table by dimensions.
3) If you are absolutely sure that you passed the correct time and the correct selection by dimensions to the parameters of the virtual table of the last slice, but when you visually view the information register, you clearly see that you are getting the wrong value, then you have a problem with the index - just re-index the register.
4) All of the above is true for the tabular and for the object data access model. I'm clarifying, since you forgot to tell how exactly you are trying to get a slice of the latter.

K
Konstantin Nagibovich, 2017-02-17
@nki

Searching in a recent slice fails if the entry with the pair is not the last.

Does the register have a periodicity?
The data would look and request.

K
Konstantin, 2017-02-18
@fosihas

But look at the screenshots of how the Register looks in the configurator.
Maybe that's the problem. How confident are you in the accuracy of the passed search parameter. Letter case, spaces...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question