2
CREATE OR REPLACE FUNCTION public.largest_polygon1(
  geom1 geometry,
  geom2 geometry)
  RETURNS geometry
  LANGUAGE 'plpgsql'

  COST 100
  VOLATILE
   AS $BODY$
  begin
   Return
    Case 
       When ST_Area(geom1) > ST_Area(geom2) Then geom1
     else geom2
    End;
  End;
 $BODY$;

  ALTER FUNCTION public.largest_polygon1(geometry, geometry)
 OWNER TO postgres;
8
  • what is not working?
    – Ian Turton
    May 20, 2019 at 10:56
  • In this code, I need to find the largest polygon of two polygons geom1 and geom2 using case statement, do you have any idea to correct this?
    – Karthik
    May 20, 2019 at 11:47
  • what happens when you run this function? what is not working?
    – Ian Turton
    May 20, 2019 at 12:09
  • 'ERROR: FEHLER: Anfrage hat keinen Bestimmungsort für die Ergebnisdaten HINT: Wenn Sie die Ergebnisse eines SELECT verwerfen wollen, verwenden Sie stattdessen PERFORM. CONTEXT: PL/pgSQL-Funktion largest_polygon1(geometry,geometry) Zeile 3 bei SQL-Anweisung SQL state: 42601' This is the error I got.
    – Karthik
    May 20, 2019 at 12:52
  • begin return Case When ST_Area(geom1) > ST_Area(geom2) Then geom1 else geom2 End; End; Then after using this I got the answer now.
    – Karthik
    May 20, 2019 at 12:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.