Выделить записи в таблице по некоторому сложному условию — различия между версиями

Материал из Фабиус wiki
Перейти к: навигация, поиск
м
м (2)
Строка 11: Строка 11:
  
 
= 2 =
 
= 2 =
 +
 +
local aa, sql, flt
 +
 +
sql := [ Select RGNUM From DOCS] + Ret_f_ext() + [ Where KINDDOC = 'ESJ' and LVLNUM = '2' and Left( CATTR5, 5 ) = '  103' and ;
 +
  ( Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '01.03' or ;
 +
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '02.03' or ;
 +
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '03.03' or ;
 +
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '04.03' or ;
 +
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '05.03' or ;
 +
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '06.03' or ;
 +
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '07.03' or ;
 +
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '08.03' or ;
 +
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '09.03' or ;
 +
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '10.03' or ;
 +
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '11.03' or ;
 +
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '12.03' or ;
 +
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '13.03' ;
 +
    ) ]
 +
 +
aa := SelectSqlToArr( sql, { 'RGNUM' } )
 +
 +
if !IsEmpty( aa )
 +
 +
  aa := PrepareArr( aa )
 +
  flt := Create_Filt_From_Arr( 'RGNUM', aa )
 +
  SetFilter( flt )
 +
  SetSelRows( , true )
 +
endif

Версия 16:59, 22 апреля 2016

1

local aa, sql, flt
sql := [ Select RGNUM From DOCS] + Ret_f_ext() + [ Where KINDDOC = 'MTR' ]
aa := SelectSqlToArr( sql, { 'RGNUM' } )
if !IsEmpty( aa )
  aa := PrepareArr( aa )
  flt := Create_Filt_From_Arr( 'RGNUM', aa )
  SetFilter( flt )
  SetSelRows( , true )
endif

2

local aa, sql, flt

sql := [ Select RGNUM From DOCS] + Ret_f_ext() + [ Where KINDDOC = 'ESJ' and LVLNUM = '2' and Left( CATTR5, 5 ) = '  103' and ;
  ( Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '01.03' or ;
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '02.03' or ;
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '03.03' or ;
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '04.03' or ;
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '05.03' or ;
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '06.03' or ;
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '07.03' or ;
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '08.03' or ;
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '09.03' or ;
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '10.03' or ;
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '11.03' or ;
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '12.03' or ;
    Left( ] + SqlField( '_TIMEFIRST',, 'sql_char' ) + [, 5 ) = '13.03' ;
    ) ]

aa := SelectSqlToArr( sql, { 'RGNUM' } )

if !IsEmpty( aa )

 aa := PrepareArr( aa )
 flt := Create_Filt_From_Arr( 'RGNUM', aa )
 SetFilter( flt )
 SetSelRows( , true )
endif