Below query works fine for me
select ST_GeomFromText('POINT(-111.7844620 32.9667050)',4326) from elec_common.abc;
geometry column has same value as above which is -111.7844620 32.9667050
however the below query shows an error
select ST_GeomFromText('POINT(geometry)',4326) from elec_common.abc;
SQL Error [XX000]: ERROR: parse error - invalid geometry Hint:
"POINT(ge" <-- parse error at position 8 within geometry
org.postgresql.util.PSQLException: ERROR: parse error - invalid
geometry Hint: "POINT(ge" <-- parse error at position 8 within
geometry
Related
We are getting below error while converting the data fie to CSV and writing the data from CSV to table.
ERROR: invalid input syntax for type numeric: " "
There is column with data type numeric while converting to CSV it is extracted as empty and same while inserting to table for the datatype numeric it is not allowing.
How to convert the numeric data type and conver the data to null.?
I need command how to convert the numeric data type column value empty string to Null while inserting into table.?
Here is a query:
SELECT ST_DistanceSpheroid(geometry(a.location), ST_GeomFromText('POINT(28.828042, 47.023565)', 4326), 'SPHEROID["WGS 84",6378137,298.257223563]')
FROM users a
WHERE a.id=1
I got this error:
ERROR: ОШИБКА: parse error - invalid geometry
HINT: "POINT(28.828042, 4" <-- parse error at position 18 within geometry
SQL state: XX000
Where did I make mistake??
Well-known Text representations of points don't need a comma. Try this:
POINT(28.828042 47.023565)
I have the following sample data for demo:
Table:
create table tbl_json
(
id json
);
Some values:
insert into tbl_json values('[{"id":1},{"id":2},{"id":3}]');
Query: Convert/cast id into integer from json column.
Tried:
select json_array_elements(id)->>'id'::int ids
from tbl_json;
Getting an error:
ERROR: invalid input syntax for integer: "id"
The ::int cast is applied to 'id' because it has a higher precedence.
select (json_array_elements(id)->>'id')::int ids
from tbl_json;
Exception (Database Exception) 'yii\db\Exception' with message
SQLSTATE[42601]: Syntax error: 7
ERROR: a column definition list is required for functions returning "record"
If you have a function that is defined as RETURNS [SETOF] record, you have to specify a column list when you call it. This is because the return type has to be known at query parse time.
An example:
SELECT * FROM myfun() AS myfun(a integer, b text);
I have a table with a uuid column, and some of the rows are missing the data. I need to insert data into this uuid column. The data is entered manually, so we are suffixing with other column data to differentiate, but it gives me an error.
UPDATE schema.table
SET uuid_column = CONCAT ('f7949f56-8840-5afa-8c6d-3b0f6e7f93e9', '-', id_column)
WHERE id_column = '1234';
Error: [42804] ERROR: column "uuid_column" is of type uuid but expression is of type text
Hint: You will need to rewrite or cast the expression.
Position: 45
I also tried
UPDATE schema.table
SET uuid_column = CONCAT ('f7949f56-8840-5afa-8c6d-3b0f6e7f93e9', '-', id_column)::uuid
WHERE id_column = '1234';
Error: [22P02] ERROR: invalid input syntax for uuid: "f7949f56-8840-5afa-8c6d-3b0f6e7f93e9-1234"
An UUID consists of 16 bytes, which you see displayed in hexadecimal notation.
You cannot have a UUID with fewer or more bytes.
I recommend using the type bytea if you really need to do such a thing.