您知道使用命名字段表示法创建 ROW 的 json_populate_record 替代方法吗?
在这个例子中:
CREATE TYPE contact AS (
firstname VARCHAR,
lastname VARCHAR
);
postgres=# SELECT json_populate_record(NULL::contact,
postgres(# '{
postgres'# "firstname": "John",
postgres'# "lastname": "Doe"
postgres'# }'
postgres'# );
json_populate_record
----------------------
(John,Doe)
(1 row)
问题:你知道像 json_populate_record
,它允许在不使用 json 格式的情况下创建具有命名字段表示法的 ROW
?
我知道 ROW
语法表达式:
postgres=# SELECT ROW('John', 'Doe')::contact;
row
------------
(John,Doe)
(1 row)
但我没有找到 ROW
构造函数 语法允许命名字段表示法。
谨致问候,
史蒂芬
In this example:
CREATE TYPE contact AS (
firstname VARCHAR,
lastname VARCHAR
);
postgres=# SELECT json_populate_record(NULL::contact,
postgres(# '{
postgres'# "firstname": "John",
postgres'# "lastname": "Doe"
postgres'# }'
postgres'# );
json_populate_record
----------------------
(John,Doe)
(1 row)
Question: do you know a method like json_populate_record
, which allows creating a ROW
with named field notation without using a json format?
I know the ROW
syntax expression:
postgres=# SELECT ROW('John', 'Doe')::contact;
row
------------
(John,Doe)
(1 row)
But I didn't find a ROW
constructors syntax allowing a named field notation.
Best regards,
Stéphane
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
行构造函数的命名参数没有选项。您可以通过定义与早期定义的类型相关的函数来模拟类似的语法,例如
在 db< 中测试它;>小提琴。
There is no option for named arguments of a row constructor. You can simulate alike syntax by defining a function related to an earlier defined type, e.g.
Test it in db<>fiddle.