-- set schema 't'; select * from finsertorder('x','b',160,40,'a'); NOTICE: owner x created CONTEXT: PL/pgSQL function fgetowner(text,boolean) line 10 at assignment PL/pgSQL function finsertorder(text,text,bigint,bigint,text) line 35 at assignment id | uuid | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows ----+------+-----+----+----------+----+----------+--------+---------+------- 8 | 1-8 | 4 | 5 | 40 | 4 | 160 | 0 | 0 | [] (1 row) select * from finsertorder('y','c',160,80,'b'); NOTICE: owner y created CONTEXT: PL/pgSQL function fgetowner(text,boolean) line 10 at assignment PL/pgSQL function finsertorder(text,text,bigint,bigint,text) line 35 at assignment id | uuid | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows ----+------+-----+----+----------+----+----------+--------+---------+------- 9 | 1-9 | 5 | 4 | 80 | 6 | 160 | 0 | 0 | [] (1 row) select * from finsertorder('t','c',100,100,'a'); NOTICE: owner t created CONTEXT: PL/pgSQL function fgetowner(text,boolean) line 10 at assignment PL/pgSQL function finsertorder(text,text,bigint,bigint,text) line 35 at assignment id | uuid | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows ----+------+-----+----+----------+----+----------+--------+---------+------- 10 | 1-10 | 6 | 5 | 100 | 6 | 100 | 0 | 0 | [] (1 row) select * from fgetquote('z','a',20,0,'c'); -- expected (qtt_prov,qtt_requ)= (20,160) NOTICE: owner z created CONTEXT: PL/pgSQL function fgetowner(text,boolean) line 10 at assignment PL/pgSQL function fgetquote(text,text,bigint,bigint,text) line 36 at assignment id | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows | created | removed ----+-----+----+----------+----+----------+--------+---------+-------------------------------------------------------------------------------------+---------+--------- 0 | 7 | 6 | 0 | 5 | 20 | 160 | 20 | {"[(8, 4, 5, 40, 4, 160, 160),(9, 5, 4, 80, 6, 160, 160),(0, 7, 6, 0, 5, 20, 20)]"} | | (1 row) select qtt_in,qtt_out from fgetquote('z','a',20,160,'c'); qtt_in | qtt_out --------+--------- 160 | 20 (1 row) select qtt_in,qtt_out from fexecquote('z',4); qtt_in | qtt_out --------+--------- 160 | 20 (1 row) select id,uuid,nb,oruuid,grp,provider,quality,qtt,receiver from vmvt order by uuid; id | uuid | nb | oruuid | grp | provider | quality | qtt | receiver ----+------+----+--------+-----+----------+---------+-----+---------- 10 | 1-10 | 3 | 1-8 | 1-9 | x | b | 80 | y 11 | 1-11 | 3 | 1-9 | 1-9 | y | c | 160 | z 9 | 1-9 | 3 | 1-11 | 1-9 | z | a | 20 | x (3 rows) select * from fgetagr('1-9') where _own='z'; -- expected as first quote (_qtt_prov,_qtt_requ)=(20,160) _own | _natp | _qtt_prov | _qtt_requ | _natr ------+-------+-----------+-----------+------- z | a | 20 | 160 | c (1 row) select * from fgetquote('z','a',100,0,'c'); -- expected (qtt_in,qtt_out)= (100,100) id | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows | created | removed ----+-----+----+----------+----+----------+--------+---------+--------------------------------------------------------------+---------+--------- 0 | 7 | 6 | 0 | 5 | 100 | 100 | 100 | {"[(10, 6, 5, 100, 6, 100, 100),(0, 7, 6, 0, 5, 100, 100)]"} | | (1 row) select * from finsertorder('z','a',100,100,'c'); -- one agreements id | uuid | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows ----+------+-----+----+----------+----+----------+--------+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | 1-12 | 7 | 6 | 100 | 5 | 100 | 100 | 100 | [[{"id":10, "own":6, "nr":5, "qtt_requ":100, "np":6, "qtt_prov":100, "qtt":100, "flowr":100 },{"id":12, "own":7, "nr":6, "qtt_requ":100, "np":5, "qtt_prov":100, "qtt":100, "flowr":100 }]+ | | | | | | | | | ] (1 row) select * from fgetagr('1-12') where _own='z'; -- expected as first quote _own | _natp | _qtt_prov | _qtt_requ | _natr ------+-------+-----------+-----------+------- z | a | 100 | 100 | c (1 row) select * from finsertorder('x','b2',160,40,'a2'); id | uuid | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows ----+------+-----+----+----------+----+----------+--------+---------+------- 13 | 1-13 | 4 | 8 | 40 | 7 | 160 | 0 | 0 | [] (1 row) select * from finsertorder('y','c2',160,80,'b2'); id | uuid | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows ----+------+-----+----+----------+----+----------+--------+---------+------- 14 | 1-14 | 5 | 7 | 80 | 9 | 160 | 0 | 0 | [] (1 row) select * from finsertorder('t','c2',90,10,'a2'); id | uuid | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows ----+------+-----+----+----------+----+----------+--------+---------+------- 15 | 1-15 | 6 | 8 | 10 | 9 | 90 | 0 | 0 | [] (1 row) select * from fgetquote('z','a2',10,0,'c2');-- expected (qtt_in,qtt_out)= (90,10) id | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows | created | removed ----+-----+----+----------+----+----------+--------+---------+---------------------------------------------------------+---------+--------- 0 | 7 | 9 | 0 | 8 | 10 | 90 | 10 | {"[(15, 6, 8, 10, 9, 90, 90),(0, 7, 9, 0, 8, 10, 10)]"} | | (1 row) select * from finsertorder('z','a2',10,90,'c2'); id | uuid | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows ----+------+-----+----+----------+----+----------+--------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 16 | 1-16 | 7 | 9 | 90 | 8 | 10 | 90 | 10 | [[{"id":15, "own":6, "nr":8, "qtt_requ":10, "np":9, "qtt_prov":90, "qtt":90, "flowr":90 },{"id":16, "own":7, "nr":9, "qtt_requ":90, "np":8, "qtt_prov":10, "qtt":10, "flowr":10 }]+ | | | | | | | | | ] (1 row) select * from fgetagr('1-14') where _own='z'; -- expected as first quote _own | _natp | _qtt_prov | _qtt_requ | _natr ------+-------+-----------+-----------+------- z | a2 | 10 | 90 | c2 (1 row) select * from fgetquote('z','a2',20,0,'c2'); -- expected (qtt_in,qtt_out)= (160,20) id | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows | created | removed ----+-----+----+----------+----+----------+--------+---------+---------------------------------------------------------------------------------------+---------+--------- 0 | 7 | 9 | 0 | 8 | 20 | 160 | 20 | {"[(13, 4, 8, 40, 7, 160, 160),(14, 5, 7, 80, 9, 160, 160),(0, 7, 9, 0, 8, 20, 20)]"} | | (1 row) select * from finsertorder('z','a2',20,160,'c2'); id | uuid | own | nr | qtt_requ | np | qtt_prov | qtt_in | qtt_out | flows ----+------+-----+----+----------+----+----------+--------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 17 | 1-17 | 7 | 9 | 160 | 8 | 20 | 160 | 20 | [[{"id":13, "own":4, "nr":8, "qtt_requ":40, "np":7, "qtt_prov":160, "qtt":160, "flowr":80 },{"id":14, "own":5, "nr":7, "qtt_requ":80, "np":9, "qtt_prov":160, "qtt":160, "flowr":160 },{"id":17, "own":7, "nr":9, "qtt_requ":160, "np":8, "qtt_prov":20, "qtt":20, "flowr":20 }]+ | | | | | | | | | ] (1 row) select * from fgetagr('1-16') where _own='z'; -- expected as first quote _own | _natp | _qtt_prov | _qtt_requ | _natr ------+-------+-----------+-----------+------- z | a2 | 20 | 160 | c2 (1 row) /* -- select * from vmvt; */