jac*_*oid 1 postgresql hstore operator
目前我有一个 hstore 来描述各种项目的属性。搜索时,我需要删除每个项目唯一的值(例如序列号、vin 等)。根据 postgresql 文档,我应该能够使用以下运算符从 hstore 中删除密钥
根据 postgres 文档
hstore - text delete key from left operand 'a=>1, b=>2, c=>3'::hstore - 'b'::text
在我的代码中,我有
IF item.details ? 'vin' THEN
item.details::hstore - 'vin'::TEXT;
END IF;
当我去创建函数时,我收到语法错误
'“::”处或附近的语法错误'
当我从值的末尾删除类型声明时,我收到错误
'“-”处或附近的语法错误'
据我所知,这符合 postgres 文档所说的操作员应该在http://www.postgresql.org/docs/9.3/static/hstore.html 上工作的方式。有什么我想念的吗?
您正在尝试将该表达式item.details::hstore - 'vin'::TEXT
用作 PL/PgSQL 语句。
结果应该去哪里?
猜测一下,我认为你打算写的是:
item.details := item.details - 'vin'::TEXT;
Run Code Online (Sandbox Code Playgroud)
即“将 item.details 设置为 item.details 的旧值并vin
删除键”。
如果没有更多背景,就很难确定。
归档时间: |
|
查看次数: |
1635 次 |
最近记录: |