ST_IsValidReason — Returns text stating if a geometry is valid or not and if not valid, a reason why.
sqlfiddle.com/
kapalı alanın vertex sayısı
SELECT distinct objectid, sum(ST_NPoints(poly)) FROM public.geoplan_fonksiyon_5000
GROUP BY objectid
ORDER BY sum
substr, replace, to_date, BMK
select
s.bilgi, s.detay1
, replace("bilgi", 'BMK=', '') as bmk
, substr(replace("bilgi", 'BMK=', ''),7,4) as yil
, substr(replace("bilgi", 'BMK=', ''),4,2) as ay
, substr(replace("bilgi", 'BMK=', ''),1,2) as gun
, substr(replace("bilgi", 'BMK=', ''),12,3) as sayi
, bsmtarih
, bsmsayi
from
planbesbin.mnip_sinir s
where
s.bilgi like 'BMK=%'
--------------------
UPDATE planbesbin.mnip_sinir s
SET bsmtarih =
to_date(
substr(replace("bilgi", 'BMK=', ''),7,4) ||'-'||
substr(replace("bilgi", 'BMK=', ''),4,2) ||'-'||
substr(replace("bilgi", 'BMK=', ''),1,2)
, 'YYYY.MM.DD'
)
,
bsmsayi = cast(substr(replace("bilgi", 'BMK=', ''),12,3) as integer)
where
s.bilgi like 'BMK=%'
s.bilgi, s.detay1
, replace("bilgi", 'BMK=', '') as bmk
, substr(replace("bilgi", 'BMK=', ''),7,4) as yil
, substr(replace("bilgi", 'BMK=', ''),4,2) as ay
, substr(replace("bilgi", 'BMK=', ''),1,2) as gun
, substr(replace("bilgi", 'BMK=', ''),12,3) as sayi
, bsmtarih
, bsmsayi
from
planbesbin.mnip_sinir s
where
s.bilgi like 'BMK=%'
--------------------
UPDATE planbesbin.mnip_sinir s
SET bsmtarih =
to_date(
substr(replace("bilgi", 'BMK=', ''),7,4) ||'-'||
substr(replace("bilgi", 'BMK=', ''),4,2) ||'-'||
substr(replace("bilgi", 'BMK=', ''),1,2)
, 'YYYY.MM.DD'
)
,
bsmsayi = cast(substr(replace("bilgi", 'BMK=', ''),12,3) as integer)
where
s.bilgi like 'BMK=%'
to_char - tarih formatı
CREATE OR REPLACE FUNCTION planbesbin.fn_bmk()
RETURNS trigger AS
$$
BEGIN
SELECT ('BMK=' || TO_CHAR(s.bsmtarih, 'DD.MM.YYYY') || '/' || s.bsmsayi )
INTO NEW.bmk
FROM
planbesbin.mnip_sinir s
,
planbesbin.mnip_cizgi c
WHERE
st_intersects (ST_StartPoint(NEW.poly), s.poly)
AND ST_Disjoint (ST_EndPoint(NEW.poly), s.poly)
AND NEW.mnip_kod = 80101 AND NEW.detay1= '1'
;
RETURN NEW;
END;
$$
LANGUAGE 'plpgsql';
----------------------
CREATE TRIGGER tg_bmk_BEFORE
BEFORE INSERT OR UPDATE ON planbesbin.mnip_cizgi
FOR EACH ROW EXECUTE PROCEDURE planbesbin.fn_bmk();
CREATE TRIGGER tg_bmk_AFTER
AFTER INSERT OR UPDATE ON planbesbin.mnip_cizgi
FOR EACH ROW EXECUTE PROCEDURE planbesbin.fn_bmk();
RETURNS trigger AS
$$
BEGIN
SELECT ('BMK=' || TO_CHAR(s.bsmtarih, 'DD.MM.YYYY') || '/' || s.bsmsayi )
INTO NEW.bmk
FROM
planbesbin.mnip_sinir s
,
planbesbin.mnip_cizgi c
WHERE
st_intersects (ST_StartPoint(NEW.poly), s.poly)
AND ST_Disjoint (ST_EndPoint(NEW.poly), s.poly)
AND NEW.mnip_kod = 80101 AND NEW.detay1= '1'
;
RETURN NEW;
END;
$$
LANGUAGE 'plpgsql';
----------------------
CREATE TRIGGER tg_bmk_BEFORE
BEFORE INSERT OR UPDATE ON planbesbin.mnip_cizgi
FOR EACH ROW EXECUTE PROCEDURE planbesbin.fn_bmk();
CREATE TRIGGER tg_bmk_AFTER
AFTER INSERT OR UPDATE ON planbesbin.mnip_cizgi
FOR EACH ROW EXECUTE PROCEDURE planbesbin.fn_bmk();
TRIGGER - bmk
CREATE OR REPLACE FUNCTION planbesbin.fn_bmk()
RETURNS trigger AS
$$
BEGIN
SELECT ('BMK=' || s.bsmtarih ||'/'|| s.bsmsayi)
INTO NEW.bmk
FROM
planbesbin.mnip_sinir s
,
planbesbin.mnip_cizgi c
WHERE
st_intersects (ST_StartPoint(NEW.poly), s.poly)
AND ST_Disjoint (ST_EndPoint(NEW.poly), s.poly)
AND NEW.mnip_kod = 80101 AND NEW.detay1= '1'
;
RETURN NEW;
END;
$$
LANGUAGE 'plpgsql';
----------------------
CREATE TRIGGER tg_bmk_BEFORE
BEFORE INSERT OR UPDATE ON planbesbin.mnip_cizgi
FOR EACH ROW EXECUTE PROCEDURE planbesbin.fn_bmk();
CREATE TRIGGER tg_bmk_AFTER
AFTER INSERT OR UPDATE ON planbesbin.mnip_cizgi
FOR EACH ROW EXECUTE PROCEDURE planbesbin.fn_bmk();
RETURNS trigger AS
$$
BEGIN
SELECT ('BMK=' || s.bsmtarih ||'/'|| s.bsmsayi)
INTO NEW.bmk
FROM
planbesbin.mnip_sinir s
,
planbesbin.mnip_cizgi c
WHERE
st_intersects (ST_StartPoint(NEW.poly), s.poly)
AND ST_Disjoint (ST_EndPoint(NEW.poly), s.poly)
AND NEW.mnip_kod = 80101 AND NEW.detay1= '1'
;
RETURN NEW;
END;
$$
LANGUAGE 'plpgsql';
----------------------
CREATE TRIGGER tg_bmk_BEFORE
BEFORE INSERT OR UPDATE ON planbesbin.mnip_cizgi
FOR EACH ROW EXECUTE PROCEDURE planbesbin.fn_bmk();
CREATE TRIGGER tg_bmk_AFTER
AFTER INSERT OR UPDATE ON planbesbin.mnip_cizgi
FOR EACH ROW EXECUTE PROCEDURE planbesbin.fn_bmk();