hstore:无法连接两个 hstore 值
hstore: cannot concatenate two hstore values
Postgres 新手,使用 v9.3,想利用 hstore
。
当我尝试连接两个 hstore
值时,出现奇怪的错误:
SELECT p.properties->'name' || p.properties->'age' FROM people p where p.id=1;
错误是:
ERROR: operator does not exist: text -> unknown
LINE 1: select n.properties->'name' || n.properties->'age' from n...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
我也试过了,没关系:
SELECT p.properties->'name'::text || p.properties->'age'::text FROM people p where p.id=1;
不过,我可以做
SELECT p.properties->'name' FROM people p where p.id=1;
SELECT p.properties->'age' FROM people p where p.id=1;
不能将同一个 hstore 中的两个 hstore 值连接起来吗?
感谢任何指点!
您可以按原样使用 CAST 函数:
SELECT CAST(p.properties->'name' AS text) || CAST(p.properties->'age' AS text) FROM people p where p.id=1;
Postgres 新手,使用 v9.3,想利用 hstore
。
当我尝试连接两个 hstore
值时,出现奇怪的错误:
SELECT p.properties->'name' || p.properties->'age' FROM people p where p.id=1;
错误是:
ERROR: operator does not exist: text -> unknown
LINE 1: select n.properties->'name' || n.properties->'age' from n...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
我也试过了,没关系:
SELECT p.properties->'name'::text || p.properties->'age'::text FROM people p where p.id=1;
不过,我可以做
SELECT p.properties->'name' FROM people p where p.id=1;
SELECT p.properties->'age' FROM people p where p.id=1;
不能将同一个 hstore 中的两个 hstore 值连接起来吗?
感谢任何指点!
您可以按原样使用 CAST 函数:
SELECT CAST(p.properties->'name' AS text) || CAST(p.properties->'age' AS text) FROM people p where p.id=1;