AXForum  
Вернуться   AXForum > Microsoft Dynamics NAV > NAV: Программирование
NAV
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 13.06.2013, 10:47   #1  
Kadawrik is offline
Kadawrik
Участник
 
279 / 11 (1) +
Регистрация: 04.11.2010
Цитата:
Сообщение от smoyk Посмотреть сообщение
В справке не нашел информации о параметрах по умолчанию для FINDSET, не подскажете, с какими она вызывается? Экспериментировать неохото)
Цитата:
FINDSET (Record)
Use this function to find a set of records in a table based on the current key and filter. The records can only be retrieved in ascending order.

Ok := Record.FINDSET([ForUpdate][, UpdateKey])
Ok

Data type: boolean

If you omit this optional return value, a run-time error occurs if the system cannot find a record. If you include a return value, the system assumes you will handle any errors. Ok can have these values:

If Ok is...
It means the record set was...

TRUE
Found

FALSE
Not found


Record

Data type: record

If the record was...
Then...

Found
The system returns the record in Record and sets any FlowField in the record to zero. You must update them using CALCFIELDS.

Not found
A run-time error occurs, if you omitted the return value Ok.


ForUpdate

Data type: boolean

Set this to FALSE if you don't intend to modify any records in the set.

Set this to TRUE if you want to modify some records in the set.

If you set this parameter to TRUE, a LOCKTABLE is immediately performed on the table before the records are read.

UpdateKey

Data type: boolean

This only applies if ForUpdate is set to TRUE.

If you are going to modify any field value within the current key, set this parameter to TRUE.

Comments
You should only use this function when you explicitly want to loop through a recordset. You should ONLY use this function in combination with REPEAT .. UNTIL.

Furthermore, FINDSET only supports descending loops. If you want to loop from the bottom up, you should use FIND(‘+’).

The general rules for using FINDSET are:

• FINDSET(FALSE,FALSE)- read-only. This uses no server cursors and the record set is read with a single server call.

• FINDSET(TRUE,FALSE)- is used to update non-key fields. This uses a cursor with a fetch buffer similar to FIND(‘-’).

• FINDSET(TRUE,TRUE)- is used to update key fields.

Note
This function is designed to optimize finding and updating sets. If you set any or both of the parameters to FALSE, you can still modify the records in the set but these updates will not be performed optimally.

Example
The following C/AL code examples show how to use the FINDSET function:

Example 1

// Looping through a set without updating it.

SalesLine.SETFILTER("Purch. Order Line No.",'<>0');

IF SalesLine.FINDSET THEN BEGIN

REPEAT

CopyLine(SalesLine);

UNTIL SalesLine.NEXT = 0;

END;



Example 2

// Looping through a set and updating a field that is not within the current key.

SalesLine.SETRANGE("Document Type",DocumentType);

SalesLine.SETRANGE("Document No.",DocumentNo);

IF SalesLine.FINDSET(TRUE, FALSE) THEN BEGIN

REPEAT

SalesLine."Location Code" := GetNewLocation(SalesLine);

SalesLine.MODIFY;

UNTIL SalesLine.NEXT = 0;

END;



Example 3

// Looping through a set and updating a field that is within the current key.

SalesShptLine.SETRANGE("Order No.",SalesLine."Document No.");

SalesShptLine.SETRANGE("Order Line No.",SalesLine."Line No.");

SalesShptLine.SETCURRENTKEY("Order No.","Order Line No.");

IF SalesShptLine.FINDSET(TRUE, TRUE) THEN BEGIN

REPEAT

SalesShptLine."Order Line No." := SalesShptLine."Order Line No." + 10000;

SalesShptLine.MODIFY;

UNTIL SalesShptLine.NEXT = 0;

END;

Старый 24.06.2013, 10:57   #2  
smoyk is offline
smoyk
Участник
 
188 / 13 (1) ++
Регистрация: 20.04.2007
Спасибо Kadawrik за цитирование справки из своего навика, у меня примерно такая же, но т.к. есть отличия, мне пришлось перечитать ее еще раз... Вопрос актуален, с какими параметрами по умолчания вызывается FINDSET? Мне не по глазам или просто с первого раза был непонятен мой вопрос?) Я так и не нашел этого...
Старый 24.06.2013, 17:00   #3  
Kadawrik is offline
Kadawrik
Участник
 
279 / 11 (1) +
Регистрация: 04.11.2010
Цитата:
Сообщение от smoyk Посмотреть сообщение
с какими параметрами по умолчания вызывается FINDSET?
Если верить приведенной выше справке, то вызов FINDSET без параметров = FINDSET(FALSE,FALSE)
Старый 01.07.2013, 01:00   #4  
RedFox is offline
RedFox
Участник
 
1,441 / 10 (0) +
Регистрация: 28.12.2004
Адрес: Киев
Цитата:
Сообщение от Kadawrik Посмотреть сообщение
Если верить приведенной выше справке, то вызов FINDSET без параметров = FINDSET(FALSE,FALSE) />
Не советовал бы я верить этим справкам.. Почитайте лучше то, что написали в "What impact does my C/AL have on SQL?"
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 22:43.