300 | | CREATE TYPE resum AS (source int, pfafcuen character varying(254)); |
301 | | |
302 | | drop if exists function spain.create_path(regclass,integer); |
303 | | CREATE OR REPLACE FUNCTION spain.create_path(_nametable regclass, downstream_point integer) |
304 | | RETURNS integer AS |
305 | | $$ |
306 | | DECLARE |
307 | | nrow int; |
308 | | row resum%rowtype; |
309 | | BEGIN |
310 | | EXECUTE 'Select count(*) FROM '|| _nametable INTO nrow; |
311 | | for row in EXECUTE 'select source, pfafcuen from '|| _nametable |
312 | | LOOP |
313 | | EXECUTE 'UPDATE '||_nametable||' t set chemin= |
314 | | spain.get_path('||downstream_point||',source) where t.source=source'; |
315 | | RAISE NOTICE 'Calculation for %', row.pfafcuen; |
316 | | end loop; |
317 | | return nrow; |
318 | | |
319 | | END |
320 | | $$ |
321 | | LANGUAGE plpgsql VOLATILE; |
322 | | |
323 | | |
324 | | select spain.create_path('spain.oria_a_rios_v2',6); |
325 | | select source from spain.oria_a_rios_v2 where pfafcuen='10037141142' |
326 | | select spain.get_path(6,40) |
327 | | Select count(*) FROM spain.oria_a_rios_v2 |
328 | | |
329 | | select * from downstream_segments('10037146457'); |
330 | | |
331 | | Select * FROM spain.oria_a_rios_v2 limit 10 |
332 | | |
333 | | }}} |
| 300 | select spain.get_path(6,source) from spain.oria_a_rios_v2 limit 10 |
| 301 | }}} |
| 302 | |
| 303 | {{{ |
| 304 | "get_path" |
| 305 | "1003714111.1003714113.10037141141.10037141142" |
| 306 | "1003714111.1003714113.1003714115.1003714117.100371413.10037141411.10037141413.10037141421.10037141422" |
| 307 | "1003714111.1003714113.1003714115.1003714117.100371413.10037141511.10037141513.10037141515.10037141517.10037141531.10037141533.10037141535.10037141537.10037141539.10037141551.10037141553.10037141555.10037141557.10037141571.10037141573.10037141575.1003714157 (...)" |
| 308 | "1003714111.1003714113.1003714115.1003714117.100371413.10037141511.10037141513.10037141515.10037141517.10037141531.10037141533.10037141535.10037141537.10037141539.10037141551.10037141553.10037141555.10037141557.10037141571.10037141573.10037141575.1003714157 (...)" |
| 309 | "1003714111.1003714113.1003714115.1003714117.100371413.10037141511.10037141513.10037141515.10037141517.10037141531.10037141533.10037141535.10037141537.10037141539.10037141551.10037141553.10037141555.10037141557.10037141571.10037141573.10037141575.1003714157 (...)" |
| 310 | "1003714111.1003714113.1003714115.1003714117.100371413.10037141511.10037141513.10037141515.10037141517.10037141531.10037141533.10037141535.10037141537.10037141539.10037141551.10037141553.10037141555.10037141557.10037141571.10037141573.10037141575.1003714157 (...)" |
| 311 | "1003714111.1003714113.1003714115.1003714117.100371413.10037141511.10037141513.10037141515.10037141517.10037141531.10037141533.10037141535.10037141537.10037141539.10037141551.10037141553.10037141555.10037141557.10037141571.10037141573.10037141575.1003714157 (...)" |
| 312 | "1003714111.1003714113.1003714115.1003714117.100371413.10037141511.10037141513.10037141515.10037141517.10037141531.10037141533.10037141535.10037141537.10037141539.10037141551.10037141553.10037141555.10037141557.10037141571.10037141573.10037141575.1003714157 (...)" |
| 313 | "1003714111.1003714113.1003714115.1003714117.100371413.10037141511.10037141513.10037141515.10037141517.10037141531.10037141533.10037141535.10037141537.10037141539.10037141551.10037141553.10037141555.10037141557.10037141571.10037141573.10037141575.1003714157 (...)" |
| 314 | "1003714111.1003714113.1003714115.1003714117.100371413.10037141511.10037141513.10037141515.10037141517.10037141531.10037141533.10037141535.10037141537.10037141539.10037141551.10037141553.10037141555.10037141557.10037141571.10037141573.10037141575.1003714157 (...)" |
| 315 | }}} |