I created a table itapp_cities
in PostGIS that stores data about cities. I added a column location
with the data type geometry
for storage longitude
and latitude
city. When I run the following query INSERT
, I get the error shown below.
INSERT
request:
INSERT INTO itapp_cities(city_id, city_name, city_code, state_id, location)
VALUES (DEFAULT,'Ada', 'ada-ok',37,POINT(34.774531000000003, -96.678344899999999));
Table definition:
CREATE TABLE itapp_cities
(
city_id bigserial NOT NULL,
city_name character varying(100) NOT NULL,
city_code character varying(5) NOT NULL DEFAULT ''::character varying,
state_id bigint NOT NULL,
location geometry,
CONSTRAINT itapp_cities_pkey PRIMARY KEY (city_id),
CONSTRAINT fk_states FOREIGN KEY (city_id)
REFERENCES itapp_states (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE
)
Mistake:
ERROR: column "location" is of type geometry but expression is of type point
LINE 2: VALUES (DEFAULT,'Ada', 'ada-ok',37,POINT(34.77453100000000...
^
HINT: You will need to rewrite or cast the expression.
********** Error **********
ERROR: column "location" is of type geometry but expression is of type point
SQL state: 42804
How to save point values inside this column? I'm new to PostGIS, so forgive me for this stupid question.
source
share