Узнать актуальность данных в глобальнике по сети — различия между версиями
Материал из wiki.standart-n.ru
Aleksnick (обсуждение | вклад) (Новая страница: «Отправьте по '''g-tasks''' запрос: <pre> execute block as declare variable MGN_CONNSTR DM_TEXT; declare variable INSERTDT DM_DATETIME; begin se…») |
Aleksnick (обсуждение | вклад) |
||
Строка 1: | Строка 1: | ||
Отправьте по '''g-tasks''' запрос: | Отправьте по '''g-tasks''' запрос: | ||
<pre> | <pre> | ||
− | + | SET TERM ^ ; | |
+ | |||
+ | create or alter procedure PR_GET_LAST_MGN_UPDATE | ||
as | as | ||
+ | declare variable CODE_PROFILE DM_ID; | ||
declare variable MGN_CONNSTR DM_TEXT; | declare variable MGN_CONNSTR DM_TEXT; | ||
declare variable INSERTDT DM_DATETIME; | declare variable INSERTDT DM_DATETIME; | ||
begin | begin | ||
+ | select P.PARAM_VALUE | ||
+ | from PARAMS P | ||
+ | where P.PARAM_ID = 'CODE_PROFILE' | ||
+ | into :CODE_PROFILE; | ||
+ | |||
select P.PARAM_VALUE | select P.PARAM_VALUE | ||
from PARAMS P | from PARAMS P | ||
Строка 11: | Строка 19: | ||
into :MGN_CONNSTR; | into :MGN_CONNSTR; | ||
− | execute statement 'select | + | if (:CODE_PROFILE is not null) then |
− | first 1 | + | if (:CODE_PROFILE>0) then |
− | z.insertdt | + | begin |
− | from zmain_dict z | + | code_profile=(-1)*(100+:code_profile); |
− | order by z.insertdt desc' | + | execute statement 'select first 1 z.insertdt from zmain_dict z order by z.insertdt desc' |
− | + | on external :MGN_CONNSTR | |
− | + | as user 'SYSDBA' password 'masterkey' | |
− | + | into :INSERTDT; | |
− | + | update or insert into REPORTS (ID, PARENT_ID, STATUS, REPORTTYPE, SORTING, CAPTION, PARAMS) | |
− | + | values (:code_profile, 0, -1, -1, 0, 'mgn_last_update', :INSERTDT) | |
− | + | matching (ID); | |
− | end | + | suspend; |
+ | end | ||
+ | end^ | ||
+ | |||
+ | SET TERM ; ^ | ||
+ | |||
+ | /* Following GRANT statetements are generated automatically */ | ||
+ | |||
+ | GRANT SELECT ON PARAMS TO PROCEDURE PR_GET_LAST_MGN_UPDATE; | ||
+ | GRANT SELECT,INSERT,UPDATE ON REPORTS TO PROCEDURE PR_GET_LAST_MGN_UPDATE; | ||
+ | |||
+ | /* Existing privileges on this procedure */ | ||
+ | |||
+ | GRANT EXECUTE ON PROCEDURE PR_GET_LAST_MGN_UPDATE TO SYSDBA; | ||
+ | |||
+ | execute procedure PR_GET_LAST_MGN_UPDATE; | ||
+ | |||
+ | drop procedure PR_GET_LAST_MGN_UPDATE; | ||
+ | |||
</pre> | </pre> | ||
После того как он выполнится, выполните запрос: | После того как он выполнится, выполните запрос: | ||
<pre> | <pre> | ||
− | select * from reports where id | + | select * from reports where id<-100 |
</pre> | </pre> |
Версия 11:51, 29 августа 2016
Отправьте по g-tasks запрос:
SET TERM ^ ; create or alter procedure PR_GET_LAST_MGN_UPDATE as declare variable CODE_PROFILE DM_ID; declare variable MGN_CONNSTR DM_TEXT; declare variable INSERTDT DM_DATETIME; begin select P.PARAM_VALUE from PARAMS P where P.PARAM_ID = 'CODE_PROFILE' into :CODE_PROFILE; select P.PARAM_VALUE from PARAMS P where P.PARAM_ID = 'MGN_CONNSTR' into :MGN_CONNSTR; if (:CODE_PROFILE is not null) then if (:CODE_PROFILE>0) then begin code_profile=(-1)*(100+:code_profile); execute statement 'select first 1 z.insertdt from zmain_dict z order by z.insertdt desc' on external :MGN_CONNSTR as user 'SYSDBA' password 'masterkey' into :INSERTDT; update or insert into REPORTS (ID, PARENT_ID, STATUS, REPORTTYPE, SORTING, CAPTION, PARAMS) values (:code_profile, 0, -1, -1, 0, 'mgn_last_update', :INSERTDT) matching (ID); suspend; end end^ SET TERM ; ^ /* Following GRANT statetements are generated automatically */ GRANT SELECT ON PARAMS TO PROCEDURE PR_GET_LAST_MGN_UPDATE; GRANT SELECT,INSERT,UPDATE ON REPORTS TO PROCEDURE PR_GET_LAST_MGN_UPDATE; /* Existing privileges on this procedure */ GRANT EXECUTE ON PROCEDURE PR_GET_LAST_MGN_UPDATE TO SYSDBA; execute procedure PR_GET_LAST_MGN_UPDATE; drop procedure PR_GET_LAST_MGN_UPDATE;
После того как он выполнится, выполните запрос:
select * from reports where id<-100