1
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;
  • what is not working? – Ian Turton May 20 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 at 11:47
  • what happens when you run this function? what is not working? – Ian Turton May 20 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 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 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.