I want to insert table lokasi from function... but when i call these function there are error... Please your answer
CREATE OR REPLACE FUNCTION insert_lokasi2
(anip character varying, aeksemplar character varying)
RETURNS boolean AS
$BODY$
DECLARE
eks integer;
tot integer;
nilai boolean;
eks1 integer;
eks2 integer;
tot2 integer;
BEGIN
select sum(CAST(eksemplar AS INT))
INTO eks
from lokasi
where nip = anip;
tot := eks + aeksemplar;
select CAST(eksemplar AS INT)
INTO eks1
from sensus
where nip = anip;
select CAST(eksemplar2 AS INT)
INTO eks2
from sensus
where nip = anip;
tot2 := eks1 + eks2;
IF (tot <> tot2) THEN
nilai := false;
else
nilai := true;
END IF;
RETURN nilai;
END
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION insert_lokasi2(character varying, character varying) OWNER TO postgres;
select * from insert_lokasi2('10.1010.4703','1');
ERROR: operator does not exist: integer + character varying
LINE 1: SELECT $1 + $2
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
QUERY: SELECT $1 + $2
CONTEXT: PL/pgSQL function "insert_lokasi2" line 12 at assignment