[postgis-users] GeometryFromText Problem
Gustavo Oliveira
gustavo.oliveira at 3WT.com.br
Thu Dec 9 12:31:50 PST 2004
Hi all!
I am trying to do a function that tranform some data into a geometry and
update a table.
It seems like that:
CREATE OR REPLACE FUNCTION atualiza_posicao()
RETURNS trigger AS
'
BEGIN
IF NEW.idviatura IS NULL THEN
RAISE EXCEPTION \'Campo viatura nao pode ser nulo\';
END IF;
IF NEW.datahora IS NULL THEN
RAISE EXCEPTION \'Viatura % sem timestamp\', NEW.idviatura;
END IF;
UPDATE historico_viatura
SET
localizacaoutm = select
transform(geometryfromtext(\'POINT(-NEW.latitude
-NEW.longitude)\',4326),40000)
WHERE
idhistorico = NEW.idhistorico;
UPDATE posicao_viatura
SET
localizacaoutm = select
transform(geometryfromtext(\'POINT(-NEW.latitude
-NEW.longitude)\',4326),40000),
datahora = NEW.datahora,
velocidade = NEW.velocidade * 1.852
WHERE
idviatura = NEW.idviatura;
RETURN NEW;
END;
'
LANGUAGE 'plpgsql' VOLATILE;
I had a problem when I try to execute it... The error follows here:
new_ae=# INSERT INTO historico_viatura (idhistorico, idviatura, latitude,
latitudep, longitude, longitudep, velocidade, datahora) VALUES
(nextval('seq_historico'), 38103, 47, 'S', 22, 'W', 45, now());
ERROR: syntax error at or near "select" at character 9
CONTEXT: PL/pgSQL function "sp_atualiza_posicao" line 12 at assignment
Does someone could help me?
Thanks a lot!
More information about the postgis-users
mailing list